Skip to content

Instantly share code, notes, and snippets.

@xPomaHx
Created June 10, 2021 22:37
Show Gist options
  • Save xPomaHx/e38489fd30135ce22da855f43220f4da to your computer and use it in GitHub Desktop.
Save xPomaHx/e38489fd30135ce22da855f43220f4da to your computer and use it in GitHub Desktop.
start in dotabuff.com/heroes/meta
(async () => {
var YY = {
a: function () {
return JSON.parse
},
b: function (t) {
if ("[object String]" != Object.prototype.toString.call(t))
return t.reverse();
for (var e = [], n = 0; n < t.length; n++) {
if (n + 1 < t.length) {
var i = t.charCodeAt(n),
r = t.charCodeAt(n + 1);
if (55296 <= i && i <= 56319 && 56320 == (64512 & r) || 768 <= r && r <= 879) {
e.unshift(t.substring(n, n + 2)),
n++;
continue
}
}
e.unshift(t[n])
}
return e.join("")
},
c: function () {
var t = "(";
return t += "]",
t += ".",
t += "}",
t += ".",
t += "&",
t += ".",
t += "@",
t += ".",
t += "#",
t += ".",
t += "\\$",
t += ".",
t += "\\*",
t = (t += ")").replace(/\./g, "|"),
new RegExp(t, "g")
},
d: function (t) {
return this.da(t)
},
da: function (t) {
var e = "",
n = t.length + t.length / 2 - t.length / 4,
i = Math.acos(n),
r = this.c();
return this.db(t.replace(r, e), i)
},
db: function (t, e) {
var n = "=",
i = t.length + t.length / 3 - t.length / 6 * e,
r = Math.asin(i);
return this.dc(t.replace(/\[/g, n), r)
},
dc: function (t, e) {
var n = "",
i = (t = t.split(n)).length + t.length / 4 - t.length / 8 * e;
t = t.reverse();
var r = Math.acos(i);
return t = t.join(n),
this.dd(t, r)
},
dd: function (t, e) {
var n = t.length + t.length / 5 - t.length / 10 * e,
i = Math.asin(n);
return this.de(atob(t), i)
},
de: function (t, e) {
var n = "",
i = (t = t.split(n)).length + t.length / 6 - t.length / 12 * e;
t = this.b(t);
var r = Math.log(i);
return t = t.join(n),
this.df(t, r)
},
df: function (t, e) {
var n = this.a(),
i = t.length + t.length / 8 - t.length / 16 * e;
Math.log(i);
return n(t)
}
}
const unknowDecode = (text) => YY.d(text);
const getWrbyUrl = (url) => fetch(url)
.then(el => el.text())
.then(text => jQuery('[data-encoded]', text))
.then(els => [...els]
.map(el => el.dataset.encoded)
.map(unknowDecode)
)
.then(el => el[2].series[1].data[4].y)
const sendToDownload = (text) => {
var textDoc = document.createElement('a');
textDoc.target = '_blank';
textDoc.download = 'myFile.txt';
textDoc.href = 'data:attachment/text,' + encodeURI(text);
textDoc.click();
}
const sleep = (ms) => new Promise(r => setTimeout(r, ms))
const urls = [...document.querySelectorAll('.link-type-hero')].map(el => el.href);
const { length } = urls;
const data = await urls.reduce((p, url, i) => {
return p.then(async (ar) => {
const heroName = url.split('/').pop();
const wr = await getWrbyUrl(url)
ar.push([heroName, wr])
console.log(`fetch progress: ${i}:${length}`)
await sleep(999)
return ar;
})
}, Promise.resolve([]))
console.log(data.sort(([, a], [, b]) => b - a))
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment