Last active
April 11, 2018 05:33
-
-
Save Sak32009/661ccebe953c392b0a6eeee01cc0c62c to your computer and use it in GitHub Desktop.
piratepowered.ga download improved
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
// ==UserScript== | |
// @name piratepowered.ga download improved | |
// @namespace sak32009-piratepowered-download-improved | |
// @description piratepowered.ga download improved | |
// @author Sak32009 | |
// @version 1.0.2 | |
// @homepageURL https://gist.github.com/Sak32009/661ccebe953c392b0a6eeee01cc0c62c/ | |
// @updateURL https://gist.github.com/Sak32009/661ccebe953c392b0a6eeee01cc0c62c/raw/sak32009-piratepowered-download-improved.user.js | |
// @downloadURL https://gist.github.com/Sak32009/661ccebe953c392b0a6eeee01cc0c62c/raw/sak32009-piratepowered-download-improved.user.js | |
// @match *://piratepowered.ga/* | |
// @grant none | |
// @run-at document-end | |
// ==/UserScript== | |
((() => { | |
function newDate(str){ | |
const year = str.substr(0, 4); | |
const month = str.substr(4, 2); | |
const day = str.substr(6, 2); | |
return `${day}/${month}/${year}`; | |
} | |
$(document).on("click", "table#main tbody td div.dselect_container", function (event) { | |
const $this = $(this); | |
const title = $this.closest("table#main tbody tr").find("td:nth-child(3)").text().trim(); | |
const urls = $this.find("a[onclick^='downloadFile(this, ']"); | |
const urlsData = {}; | |
const urlsLength = urls.length; | |
let urlsPLen = 0; | |
if(urlsLength > 0){ | |
window.alert("Wait...."); | |
urls.each((_index, _dom) => { | |
const $dom = $(_dom); | |
const attrOnClick = $dom.attr("onclick").replace("downloadFile(", "").replace(")", "").split(","); | |
const index = attrOnClick[1].trim(); | |
const date = attrOnClick[2].trim(); | |
const appid = attrOnClick[3].trim(); | |
$.post("/", {action: "download", appid, date, index}, ({success, data}) => { | |
if (success) { | |
if(typeof urlsData[date] === "undefined"){ | |
urlsData[date] = []; | |
} | |
urlsData[date].push(data); | |
urlsPLen += 1; | |
} | |
if (urlsPLen === urlsLength) { | |
let body = `<html><head><title>${title} - piratepowered.ga</title></head><body>`; | |
$.each(Object.keys(urlsData).reverse(), (__index, __value) => { | |
const __values = urlsData[__value]; | |
body += `<h3>${title} - ${newDate(__value)}</h3><hr>`; | |
$.each(__values, (___index, ___value) => { | |
body += `<a href='${___value}' target='_blank'>${___value}</a><br>`; | |
}); | |
body += "<hr>"; | |
}); | |
body += "<br><br><a href='https://gist.github.com/Sak32009/661ccebe953c392b0a6eeee01cc0c62c/'>© Sak32009</a></body></html>"; | |
window.open().document.body.innerHTML = body; | |
} | |
}, "json"); | |
}); | |
} | |
}); | |
})()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment