feat: Add Chrome Network Monitor extension with popup UI and request handling
- Implemented popup.html for user interface with search functionality and request display. - Developed popup.js to manage search items, matched requests, and clipboard operations. - Created mergeConflictManager.js for automated git operations in specified repositories. - Added projects.txt to maintain a list of relevant projects. - Introduced pushReleaseBranches.js for managing release branches across multiple projects. - Developed releasePrepper.js to prepare projects for release with branch management. - Created stashUpdater.js to update git origins for projects. - Added updatedProjects.txt to track projects that have been updated.
This commit is contained in:
@@ -9,8 +9,9 @@
|
||||
* @param {string} filePath - The path to the JavaScript file.
|
||||
* @returns {string} The generated bookmarklet.
|
||||
*/
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import clipboardy from 'clipboardy';
|
||||
|
||||
// Get the file path from command line arguments
|
||||
const filePath = process.argv[2];
|
||||
@@ -18,11 +19,38 @@ const filePath = process.argv[2];
|
||||
// Read the JavaScript file
|
||||
const jsCode = fs.readFileSync(filePath, 'utf8');
|
||||
|
||||
const cleanedCode = jsCode.replace(/\/\*[\s\S]*?\*\//, '');
|
||||
// Remove multiline comments and single-line comments, but preserve string literals
|
||||
let cleanedCode = jsCode
|
||||
// Remove multiline comments
|
||||
.replace(/\/\*[\s\S]*?\*\//g, '')
|
||||
// Remove single-line comments (but not URLs)
|
||||
.replace(/\/\/.*$/gm, '')
|
||||
// Remove empty lines and extra whitespace
|
||||
.replace(/^\s*\n/gm, '')
|
||||
.trim();
|
||||
|
||||
// Create the bookmarklet
|
||||
const bookmarklet = `javascript:(function() {
|
||||
${cleanedCode}
|
||||
})();`;
|
||||
|
||||
console.log(bookmarklet);
|
||||
// Validate the generated JavaScript
|
||||
try {
|
||||
// Test if the code is syntactically valid
|
||||
new Function(cleanedCode);
|
||||
console.log('Generated bookmarklet is syntactically valid.');
|
||||
} catch (syntaxError) {
|
||||
console.error('Syntax error in generated code:', syntaxError.message);
|
||||
console.log('Generated code:');
|
||||
console.log(cleanedCode);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Copy the bookmarklet to the clipboard
|
||||
try {
|
||||
clipboardy.writeSync(bookmarklet);
|
||||
console.log('Bookmarklet copied to clipboard successfully.');
|
||||
console.log('Length:', bookmarklet.length, 'characters');
|
||||
} catch (error) {
|
||||
console.error('Failed to copy bookmarklet to clipboard:', error);
|
||||
}
|
||||
Reference in New Issue
Block a user