Created
March 2, 2020 15:13
-
-
Save HerrCraziDev/44ae6d3355954096810ea9b8971cd98d to your computer and use it in GitHub Desktop.
Reverse-engineered script injected by HakuNeko to un-scramble the links list based on the first image link.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Promise((resolve, reject) => { | |
function getImage() { | |
resolve( [...this.document.querySelectorAll("div#image a img")].map(el => el.src) ); | |
} | |
function getImageFromHtml() { | |
console.log("green yoda dongers") | |
let pageCode = new this.URL(this.document.querySelector("div.container select#pages option").dataset.img).pathname.split('.').shift().split(''); | |
let imageCode = new this.URL(this.document.querySelector("#image a img").src).pathname.split('.').shift().split(''); | |
let finalCode = {}; | |
for (let i = 0x0; i < pageCode.length; i++) { | |
finalCode[pageCode[i]] = imageCode[i]; | |
console.log(`finalCode[${pageCode[i]}] = ${imageCode[i]}`) | |
} | |
let pagesList = this.document.querySelectorAll("div.container select#pages option"); | |
pagesList = [...pagesList].map(el => { | |
let finalURL = new this.URL(el.dataset.img); | |
let urlFields = finalURL.pathname.split('.'); | |
urlFields[0] = urlFields[0].split('').map(f => finalCode[f]).join(''); | |
finalURL.pathname = urlFields.join('.'); | |
return finalURL.href; | |
}); | |
console.log(pagesList) | |
resolve(pagesList); | |
} | |
function getCanvas() { | |
reject(new Error("Single-page with scrambled images is not yet supported!")); | |
} | |
function getCanvasFromHtml() { | |
let pagesListItems = [...this.document.querySelectorAll("div.container select#pages option")]; | |
let pagesURLs = pagesListItems.map(el => new this.URL(el.value, window.location.href).href); | |
resolve(pagesURLs); | |
} | |
this.setTimeout(() => { | |
try { | |
let imgOut = this.document.querySelector("div#image a img") && !![]; | |
let canvasOut = this.document.querySelector("div#image a canvas") && !![]; | |
let isHtml = this.document.querySelector("div#image").dataset.nextLink.endsWith(".html"); | |
let isnotHtml = !isHtml; | |
switch (!![]) { | |
case (isnotHtml && imgOut): | |
return getImage(); | |
case (isHtml && imgOut): | |
return getImageFromHtml(); | |
case (isnotHtml && canvasOut): | |
return getCanvas(); | |
case (isHtml && canvasOut): | |
return getCanvasFromHtml(); | |
default: | |
reject(new Error("Unknown condition could not be processed!")); | |
} | |
} catch (err) { | |
reject(err); | |
} | |
}, 2500); | |
}); | |
console.log("hakuneko_uo loaded") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment