ccloli / E-Hentai-Downloader

Download E-Hentai archive as zip file
GNU General Public License v3.0
1.82k stars 137 forks source link

Wrap third-party code in a function #227

Open AlttiRi opened 1 year ago

AlttiRi commented 1 year ago

I think it would be convenient to work with, or debug the userscript's code (the result userscript.js bundle) if the third-party code would be in a function in order to easily collapse it with the code editor functional.


// "imports"
const JSZip = getJSZip();

// your code
// ...

function getJSZip() {
// JSZip code
// ...
  return JSZip;
}

With this approach the main userscript code is at top of the file.

or

// "imports"
const JSZip = getJSZip();

// this function's code can be collapsed
function getJSZip() {
// JSZip code
// ...
  return JSZip;
}

// your code
// ...

With this approach the third-party code can be collapsed into 1 line with the basic code editor functional by one click and then you will see the the main userscript code.