1+ const fs = require ( 'fs' ) ;
2+ const path = require ( 'path' ) ;
3+ const manifest = require ( './manifest.json' ) ;
4+
5+
6+ // 要添加到文件头部的内容
7+ const headerContent = `
8+ // ==UserScript==
9+ // @name ${ manifest . name }
10+ // @namespace Violentmonkey Scripts
11+ // @match *://*.figma.com/*
12+ // @grant none
13+ // @version ${ manifest . version }
14+ // @author figma.cool,Yancy Min,Coiven,YorKun,Pluwen,Neko,诺墨 and ts8zs
15+ // @description ${ manifest . description }
16+ // @license GPL-3.0 license
17+ // ==/UserScript==
18+
19+ ` ;
20+
21+ const inputFilePath = path . join ( __dirname , 'js/content.js' ) ;
22+ const outputFolderPath = path . join ( __dirname , 'dist' ) ;
23+ const outputFilePath = path . join ( outputFolderPath , 'main.js' ) ;
24+
25+ fs . readFile ( inputFilePath , 'utf8' , ( err , data ) => {
26+ if ( err ) {
27+ console . error ( 'Error reading input file:' , err ) ;
28+ return ;
29+ }
30+
31+ const newContent = headerContent + data ;
32+
33+ try {
34+ if ( ! fs . existsSync ( outputFolderPath ) ) {
35+ fs . mkdirSync ( outputFolderPath ) ;
36+ }
37+ } catch ( err ) {
38+ console . error ( err ) ;
39+ }
40+
41+ fs . writeFile ( outputFilePath , newContent , 'utf8' , ( err ) => {
42+ if ( err ) {
43+ console . error ( 'Error writing to output file:' , err ) ;
44+ return ;
45+ }
46+
47+ console . log ( 'File successfully updated and saved to' , outputFilePath ) ;
48+ } ) ;
49+ } ) ;
0 commit comments