Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sak32009/661ccebe953c392b0a6eeee01cc0c62c to your computer and use it in GitHub Desktop.
Save Sak32009/661ccebe953c392b0a6eeee01cc0c62c to your computer and use it in GitHub Desktop.
piratepowered.ga download improved
// ==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/'>&copy; 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