ai-nevermore 0.0.7 → 0.0.9
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/README.md +13 -4
- package/bin/nevermore +29 -0
- package/dore_raven.jpeg +0 -0
- package/foo.html +1148 -0
- package/nevermore.html +133 -0
- package/out.css +11 -0
- package/out.html +125 -0
- package/package.json +3 -1
- package/src/encoded-image-component.mjs +22 -4
- package/src/html.mjs +60 -0
- package/src/image.mjs +2 -2
- package/src/index.mjs +1 -1
- package/src/render-modes.mjs +4 -2
- package/test.html +1148 -0
package/README.md
CHANGED
|
@@ -7,11 +7,11 @@ Text
|
|
|
7
7
|
---
|
|
8
8
|
while a user will see
|
|
9
9
|
|
|
10
|
-

|
|
11
11
|
|
|
12
12
|
A scraper coming to your site will see something like
|
|
13
13
|
|
|
14
|
-

|
|
15
15
|
|
|
16
16
|
Which will both prevent the scraper from acquiring your content as well as [poisoning the model trained](https://en.wikipedia.org/wiki/Adversarial_machine_learning#Data_poisoning) from it.
|
|
17
17
|
|
|
@@ -53,6 +53,14 @@ Then you include the encoded image along with it's key(This uses the source dire
|
|
|
53
53
|
</html>
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
Markup
|
|
57
|
+
------
|
|
58
|
+
Nevermore can traverse and inline transform all text and image elements in an HTML body.
|
|
59
|
+
|
|
60
|
+
`nevermore pseudomarkup <target> --unified-output <output location>`
|
|
61
|
+
|
|
62
|
+
this puts imports, styles and image decodes all inline.
|
|
63
|
+
|
|
56
64
|
Programmatic Usage
|
|
57
65
|
------------------
|
|
58
66
|
This library can be used to generate the html and css:
|
|
@@ -84,8 +92,9 @@ Install with `npm install -g ai-nevermore`
|
|
|
84
92
|
nevermore [command]
|
|
85
93
|
|
|
86
94
|
Commands:
|
|
87
|
-
nevermore pseudotext [input-file]
|
|
88
|
-
nevermore pseudoimage [input-file]
|
|
95
|
+
nevermore pseudotext [input-file] transform text to poison
|
|
96
|
+
nevermore pseudoimage [input-file] transform XOR image encoding
|
|
97
|
+
nevermore pseudomarkup [input-file] transform html content
|
|
89
98
|
|
|
90
99
|
Options:
|
|
91
100
|
--version Show version number [boolean]
|
package/bin/nevermore
CHANGED
|
@@ -3,7 +3,9 @@ import yargs from 'yargs';
|
|
|
3
3
|
import { hideBin } from 'yargs/helpers';
|
|
4
4
|
import { computeIndexKeys, generateHTMLAndCSS } from '../src/index.mjs';
|
|
5
5
|
import { NevermoreImage } from '../src/image.mjs';
|
|
6
|
+
import { transformHTML } from '../src/html.mjs'
|
|
6
7
|
import { Canvas } from '@environment-safe/canvas';
|
|
8
|
+
import { parse } from 'parse5';
|
|
7
9
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
8
10
|
import { join } from 'node:path';
|
|
9
11
|
const { cwd } = process;
|
|
@@ -100,6 +102,7 @@ yargs(hideBin(process.argv))
|
|
|
100
102
|
let canvas = null;
|
|
101
103
|
if(argv['encode']){
|
|
102
104
|
canvas = await image.encode();
|
|
105
|
+
console.log('KEY:', image.key);
|
|
103
106
|
}
|
|
104
107
|
if(argv['decode']){
|
|
105
108
|
canvas = await image.decode();
|
|
@@ -108,6 +111,32 @@ yargs(hideBin(process.argv))
|
|
|
108
111
|
}else{
|
|
109
112
|
throw new Error('piped output not yet supported');
|
|
110
113
|
}
|
|
114
|
+
}).command('pseudomarkup [input-file]', 'transform html content', (yargs) => {
|
|
115
|
+
return yargs
|
|
116
|
+
.positional('input-file', {
|
|
117
|
+
describe: 'file input'
|
|
118
|
+
})
|
|
119
|
+
}, async (argv) => {
|
|
120
|
+
let result = null;
|
|
121
|
+
if(!argv['input-file']){
|
|
122
|
+
//TODO: pipe support
|
|
123
|
+
throw new Error('pipe not yet supported');
|
|
124
|
+
}else{
|
|
125
|
+
const target = await readFile(argv['input-file']);
|
|
126
|
+
const parsed = parse(target.toString());
|
|
127
|
+
let idx = null;
|
|
128
|
+
if(argv['custom-dictionary']){
|
|
129
|
+
const result = await readFile(argv['custom-dictionary']);
|
|
130
|
+
idx = result.toString();
|
|
131
|
+
}
|
|
132
|
+
result = await transformHTML(parsed, idx);
|
|
133
|
+
}
|
|
134
|
+
if(result && argv['unified-output']){
|
|
135
|
+
await writeFile(argv['unified-output'], result);
|
|
136
|
+
}else{
|
|
137
|
+
console.log(result);
|
|
138
|
+
//throw new Error('piped output not yet supported');
|
|
139
|
+
}
|
|
111
140
|
}).option('key', {
|
|
112
141
|
alias: 'K',
|
|
113
142
|
type: 'string',
|
package/dore_raven.jpeg
ADDED
|
Binary file
|