jizy-obfuscator 1.0.1
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/LICENSE +21 -0
- package/README.md +49 -0
- package/dist/js/jizy-obfuscator.min.js +2 -0
- package/lib/index.js +5 -0
- package/lib/js/Obfuscator.js +15 -0
- package/lib/js/Rot13.js +35 -0
- package/package.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-present Joffrey Demetz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# jizy-obfuscator
|
|
2
|
+
|
|
3
|
+
Un-obfuscate email addresses (and other sensitive strings) in the DOM at runtime, keeping them hidden from most scrapers.
|
|
4
|
+
|
|
5
|
+
Content is stored ROT13-encoded inside placeholder elements and decoded client-side on page load.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install jizy-obfuscator
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## How it works
|
|
14
|
+
|
|
15
|
+
1. Server-side, encode each email with ROT13 and emit a placeholder with a matching id:
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
Contact: <span id="obfuscated-0"></span>
|
|
19
|
+
Support: <span id="obfuscated-1"></span>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
2. Client-side, pass the ROT13-encoded strings (in the same order as the ids) to `Obfuscator.decode`:
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import { Obfuscator } from 'jizy-obfuscator';
|
|
26
|
+
|
|
27
|
+
Obfuscator.decode([
|
|
28
|
+
'<n uers="znvygb:wbr@rknzcyr.pbz">wbr@rknzcyr.pbz</n>', // -> <a href="mailto:joe@example.com">joe@example.com</a>
|
|
29
|
+
'<n uers="znvygb:fhccbeg@rknzcyr.pbz">fhccbeg@rknzcyr.pbz</n>'
|
|
30
|
+
]);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Each entry replaces `#obfuscated-<index>` via `outerHTML`, so the decoded HTML can include links or any markup.
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
### `Obfuscator.decode(obfuscated)`
|
|
38
|
+
|
|
39
|
+
- `obfuscated` — `string[]` of ROT13-encoded HTML fragments. Index `i` replaces the element `#obfuscated-i`.
|
|
40
|
+
|
|
41
|
+
ROT13 is its own inverse: encode and decode use the same transform. Non-letter characters (digits, `@`, `.`, tags, attributes) pass through unchanged.
|
|
42
|
+
|
|
43
|
+
## Browser build
|
|
44
|
+
|
|
45
|
+
A prebuilt bundle is available at `dist/js/jizy-obfuscator.min.js` for direct `<script>` inclusion.
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
MIT © Joffrey Demetz
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! Obfuscator v1.0.0 | MIT | 2026-04-15T09:11Z | [default] */
|
|
2
|
+
!function(t){"use strict";if("object"!=typeof t||!t||!t.document)throw new Error("Obfuscator requires a window with a document");if(void 0!==t.Obfuscator)throw new Error("Obfuscator is already defined");var e=function(){const t={map:null,convert:function(t){this.init();let e="";for(let r=0;r<t.length;r++){const o=t.charAt(r);e+=o>="A"&&o<="Z"||o>="a"&&o<="z"?this.map[o]:o}return e},init:function(){if(null!=this.map)return;const t=[],e="abcdefghijklmnopqrstuvwxyz";for(let r=0;r<26;r++)t[e.charAt(r)]=e.charAt((r+13)%26);for(let r=0;r<26;r++)t[e.charAt(r).toUpperCase()]=e.charAt((r+13)%26).toUpperCase();this.map=t}};return{decode:function(e){if(e&&e.length)for(let r=0,o=e.length;r<o;r++)document.querySelector("#obfuscated-"+r).outerHTML=t.convert(e[r])}}}();t.Obfuscator=e}("undefined"!=typeof window?window:this);
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Rot13 from './Rot13.js';
|
|
2
|
+
|
|
3
|
+
const Obfuscator = {
|
|
4
|
+
decode: function (obfuscated) {
|
|
5
|
+
if (!obfuscated || !obfuscated.length) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
for (let i = 0, n = obfuscated.length; i < n; i++) {
|
|
10
|
+
document.querySelector("#obfuscated-" + i).outerHTML = Rot13.convert(obfuscated[i]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default Obfuscator;
|
package/lib/js/Rot13.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const Rot13 = {
|
|
2
|
+
map: null,
|
|
3
|
+
|
|
4
|
+
convert: function (a) {
|
|
5
|
+
this.init();
|
|
6
|
+
|
|
7
|
+
let s = "";
|
|
8
|
+
for (let i = 0; i < a.length; i++) {
|
|
9
|
+
const b = a.charAt(i);
|
|
10
|
+
s += ((b >= 'A' && b <= 'Z') || (b >= 'a' && b <= 'z') ? this.map[b] : b);
|
|
11
|
+
}
|
|
12
|
+
return s;
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
init: function () {
|
|
16
|
+
if (this.map != null) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const map = [];
|
|
21
|
+
const s = "abcdefghijklmnopqrstuvwxyz";
|
|
22
|
+
|
|
23
|
+
for (let i = 0; i < s.length; i++) {
|
|
24
|
+
map[s.charAt(i)] = s.charAt((i + 13) % 26);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
for (let i = 0; i < s.length; i++) {
|
|
28
|
+
map[s.charAt(i).toUpperCase()] = s.charAt((i + 13) % 26).toUpperCase();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
this.map = map;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default Rot13;
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jizy-obfuscator",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"browser": "dist/js/jizy-obfuscator.min.js",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"jizy": "dist/",
|
|
8
|
+
"licence": "MIT",
|
|
9
|
+
"homepage": "https://jdz.joffreydemetz.com/jizy-obfuscator",
|
|
10
|
+
"description": "UnObfuscate email addresses from the DOM",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"jdz",
|
|
13
|
+
"jizy",
|
|
14
|
+
"joffreydemetz",
|
|
15
|
+
"obfuscator"
|
|
16
|
+
],
|
|
17
|
+
"files": [
|
|
18
|
+
"dist/*",
|
|
19
|
+
"lib/*"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"jpack:dist": "node ./cli/jpack.js"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"jizy-packer": "^2.1.44",
|
|
26
|
+
"less": "^4.4.2"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/joffreydemetz/jizy-obfuscator.git"
|
|
31
|
+
},
|
|
32
|
+
"author": "Joffrey Demetz <joffrey.demetz@gmail.com> (https://joffreydemetz.com)"
|
|
33
|
+
}
|