Skip to content

Commit

Permalink
[feature] replaceStaleToken
Browse files Browse the repository at this point in the history
  • Loading branch information
shuji-koike committed Oct 30, 2020
1 parent 135c32e commit 718db52
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions extension/content_script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Tesseract from "tesseract.js";
// https://developer.chrome.com/extensions/content_scripts

unCaptcha();
replaceStaleToken();

export async function unCaptcha() {
const img = document.querySelector(
Expand All @@ -20,6 +21,22 @@ export async function unCaptcha() {
input.value = text;
}

function replaceStaleToken() {
const selector = "input[name='org.apache.struts.taglib.html.TOKEN']";
const token = document.querySelector<HTMLInputElement>(selector)?.value;
if (token) {
const tokens: string[] = JSON.parse(
sessionStorage.getItem("rains-tokens") || "[]"
);
if (tokens.includes(token))
[...document.querySelectorAll<HTMLInputElement>(selector)].forEach(
(e) => (e.value = tokens[tokens.length - 1])
);
else tokens.push(token);
sessionStorage.setItem("rains-tokens", JSON.stringify(tokens));
}
}

document
.querySelectorAll(
"body > table > tbody > tr > td > form:nth-child(6) > table:nth-child(30) > tbody > tr > td > table > tbody > tr:nth-child(1) > td:nth-child(1)"
Expand Down

0 comments on commit 718db52

Please sign in to comment.