diff --git a/rollup.config.js b/rollup.config.js index dfea5fa..63cddc4 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -15,8 +15,9 @@ const getBannerText = () => { return bannerText } -const getIntro = () => { - return fs.readFileSync("./src/intro.js", "utf-8") +const getWrapper = (startL, endL) => { + const js = fs.readFileSync("./src/wrapper.js", "utf-8") + return js.split(/\n/g).slice(startL, endL).join("\n") } const basePlugins = [ @@ -87,8 +88,8 @@ export default [ format: "iife", sourcemap: false, banner: getBannerText, - intro: getIntro, - outro: "}.toString() + ')()');document.body.prepend(d)})" + intro: () => getWrapper(0, -1), + outro: () => getWrapper(-1) }, plugins, }, diff --git a/src/intro.js b/src/wrapper.js similarity index 93% rename from src/intro.js rename to src/wrapper.js index 3e42822..1e237db 100644 --- a/src/intro.js +++ b/src/wrapper.js @@ -1,3 +1,4 @@ +/* eslint-disable */ const w = typeof unsafeWindow == 'object' ? unsafeWindow : window; // GM APIs glue @@ -38,3 +39,6 @@ new Promise(resolve => { d.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='; d.once = false; d.setAttribute('onload', `if(this.once)return;this.once=true;this.remove();const GM=window['${gmId}'];delete window['${gmId}'];(` + function a () { + /** script code here */ + +}.toString() + ')()');document.body.prepend(d)}) \ No newline at end of file