Created
April 2, 2018 03:34
-
-
Save icetee/6b49dc50c07c29fff4a72d45498e9dc2 to your computer and use it in GitHub Desktop.
Whatnext.eu export in JSON.
This file contains 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
/** | |
* Használat: | |
* | |
* Bejelentkezés után, menj a http://whatnext.eu/koveto oldalra. | |
* Csoportosított sorozatonként lehet letölteni JSON formában. | |
* Devtool-ban lévő konzolba futtasd le. | |
* Amikor már látod, hogy hosszabb idő elteltével nincs újabb mentés, akkor | |
* add ki ezt a parancsot: | |
* | |
* downloadObjectAsJson(export); | |
* | |
*/ | |
const exports = {}; | |
const getSeason = (sid, season, all, meta) => { | |
if (typeof exports[sid] === 'undefined') exports[sid] = meta; | |
if (sid - 0 === 4605) return; // MythBusters bugs... | |
$.ajax({ | |
type: "POST", | |
url: "/call.php?section=koveto", | |
data: `do=render_season&sid=${sid}&season=${season}&all=${all}`, | |
success: function(data) { | |
const parsedData = JSON.parse(data); | |
const $season = $(parsedData.season); | |
if (typeof exports[sid] === 'undefined') { | |
exports[sid] = meta; | |
} | |
exports[sid].season[season] = []; | |
$($season).each((i, item) => { | |
const $item = $(item); | |
const s = $item.attr('s'); | |
if (typeof s !== 'undefined') { | |
exports[sid].season[season].push(s === '1'); | |
} | |
}); | |
console.log('Saved Season ', sid, season, all); | |
} | |
}); | |
}; | |
var $kbox = $('.kbox'); | |
$kbox.each((index, elem) => { | |
var $this = $(elem), | |
$a = $this.find('> a'), | |
$mods = $this.find('.mod-box'), | |
id = $this[0].id.replace('id_', ''), | |
name = $a.attr('oldtitle'); | |
$mods = $mods.filter((i, elem) => /^render_season/.test($(elem).attr('onclick'))); | |
$mods.each((i, item) => { | |
const m = $(item).attr('onclick').match(/render_season\('(\d*)', '(\d*)', '(\d*)'\)/); | |
setTimeout(() => { | |
getSeason(m[1], m[2], m[3], { | |
id: id - 0, | |
name: name, | |
season: {}, | |
}); | |
}, index * 1500); // Load balancing... | |
}); | |
}); | |
const downloadObjectAsJson = function(exportObj, exportName = 'whatnext.eu') { | |
var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(exportObj)); | |
var downloadAnchorNode = document.createElement('a'); | |
downloadAnchorNode.setAttribute("href", dataStr); | |
downloadAnchorNode.setAttribute("download", exportName + ".json"); | |
downloadAnchorNode.click(); | |
downloadAnchorNode.remove(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment