Updated all bookmarklets to just be functions and we can use utils/bookmarkletMaker.js to generate the bookmarklets in the console for now.
This commit is contained in:
28
src/utils/bookmarkletMaker.js
Normal file
28
src/utils/bookmarkletMaker.js
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
/**
|
||||
* This script generates a bookmarklet from a JavaScript file.
|
||||
* It reads the JavaScript file, removes any multiline comments, and creates a bookmarklet string.
|
||||
* The bookmarklet can then be used to execute the JavaScript code in a browser.
|
||||
*
|
||||
* Use this to generate a bookmarklet from a JavaScript file in the utils/bookmarklets directory.
|
||||
*
|
||||
* @param {string} filePath - The path to the JavaScript file.
|
||||
* @returns {string} The generated bookmarklet.
|
||||
*/
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Get the file path from command line arguments
|
||||
const filePath = process.argv[2];
|
||||
|
||||
// Read the JavaScript file
|
||||
const jsCode = fs.readFileSync(filePath, 'utf8');
|
||||
|
||||
const cleanedCode = jsCode.replace(/\/\*[\s\S]*?\*\//, '');
|
||||
|
||||
// Create the bookmarklet
|
||||
const bookmarklet = `javascript:(function() {
|
||||
${cleanedCode}
|
||||
})();`;
|
||||
|
||||
console.log(bookmarklet);
|
||||
Reference in New Issue
Block a user