@painsel/add-no-ai-badge 1.0.0
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/cli.js +53 -0
- package/package.json +19 -0
package/cli.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const readline = require('readline');
|
|
6
|
+
|
|
7
|
+
const rl = readline.createInterface({
|
|
8
|
+
input: process.stdin,
|
|
9
|
+
output: process.stdout
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const SCRIPT_URL = 'https://random-stuff.britishdex.workers.dev/no-ai-badge-embed/embed-badge.js';
|
|
13
|
+
|
|
14
|
+
console.log('🛡️ Welcome to the No-AI Badge CLI Setup!');
|
|
15
|
+
console.log('-------------------------------------------');
|
|
16
|
+
|
|
17
|
+
rl.question('What position do you want the badge? (bottom-right/bottom-left/top-right/top-left) [bottom-right]: ', (pos) => {
|
|
18
|
+
pos = pos || 'bottom-right';
|
|
19
|
+
|
|
20
|
+
rl.question('Enable anti-scraper runaway physics? (y/N) [N]: ', (physics) => {
|
|
21
|
+
const hasPhysics = physics.toLowerCase() === 'y';
|
|
22
|
+
|
|
23
|
+
// Find index.html
|
|
24
|
+
const indexPath = path.join(process.cwd(), 'index.html');
|
|
25
|
+
if (!fs.existsSync(indexPath)) {
|
|
26
|
+
console.error('❌ Could not find index.html in the current directory.');
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let content = fs.readFileSync(indexPath, 'utf8');
|
|
31
|
+
|
|
32
|
+
if (content.includes(SCRIPT_URL)) {
|
|
33
|
+
console.log('✅ The No-AI Badge is already installed in your index.html!');
|
|
34
|
+
process.exit(0);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let snippet = `\n <script src="${SCRIPT_URL}"`;
|
|
38
|
+
if (pos !== 'bottom-right') snippet += ` data-position="${pos}"`;
|
|
39
|
+
if (hasPhysics) snippet += ` data-physics="true"`;
|
|
40
|
+
snippet += `></script>\n`;
|
|
41
|
+
|
|
42
|
+
// Inject before </body>
|
|
43
|
+
if (content.includes('</body>')) {
|
|
44
|
+
content = content.replace('</body>', snippet + '</body>');
|
|
45
|
+
fs.writeFileSync(indexPath, content, 'utf8');
|
|
46
|
+
console.log('✅ Successfully injected the No-AI Badge into index.html!');
|
|
47
|
+
} else {
|
|
48
|
+
console.error('❌ Could not find </body> tag in your index.html.');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
rl.close();
|
|
52
|
+
});
|
|
53
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@painsel/add-no-ai-badge",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI tool to automatically inject the No-AI Badge into your website",
|
|
5
|
+
"main": "cli.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"add-no-ai-badge": "./cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"no-ai",
|
|
14
|
+
"badge",
|
|
15
|
+
"anti-scraping"
|
|
16
|
+
],
|
|
17
|
+
"author": "painsel",
|
|
18
|
+
"license": "ISC"
|
|
19
|
+
}
|