-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathosapublishing.org.decaptcha.user.js
58 lines (52 loc) · 1.17 KB
/
osapublishing.org.decaptcha.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// ==UserScript==
// @name osapublishing_decaptcha
// @description Automatically solves the captcha for OSAPublishing
// @author KOLANICH
// @version 0.1
// @license Unlicense
// @grant none
// @run-at document-idle
// @match https://www.osapublishing.org/captcha/*
// ==/UserScript==
"use strict";
var remaps = [
// depend each time from the generated font. Need to apply contour analysis.
];
function* range(start, stop) {
for (let i = 0; i <= stop; ++i) {
yield i;
}
}
function remapChar(cp) {
let c;
for (let r of remaps) {
let [crange, replacement] = r;
if (crange instanceof Array) {
let l = crange[0].codePointAt(0);
let r = crange[1].codePointAt(0);
if (l <= cp && cp <= r) {
c = String.fromCodePoint(replacement.codePointAt(cp - l));
break;
}
} else {
if (c == crange.codePointAt(0)) {
c = replacement;
break;
}
}
}
return c;
}
function remapStr(s) {
let res = [];
for (let c of s) {
let r = remapChar(c.codePointAt(0));
if(typeof r == "undefined"){
r = c;
}
res.push(r);
}
return res.join("");
}
var p = document.getElementsByClassName("puzzle")[0];
document.getElementById("Answer").value = remapStr(p.textContent);