Skip to content

Instantly share code, notes, and snippets.

@girst
Last active October 1, 2019 16:00
Show Gist options
  • Save girst/fcc154a3c291ed690989050a9a408fc4 to your computer and use it in GitHub Desktop.
Save girst/fcc154a3c291ed690989050a9a408fc4 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Epaper Downloader
// @author Tobias Girstmair
// @namespace net.isticktoit.epaperdl-v1.1
// @description Prepare the download of the currently opended issue
// @include https://epaper.derstandard.at/issue.act?issueId=*
// @version 1.2
// @grant none
// ==/UserScript==
/*
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
License Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Script Copyright (C) 2016 Tobias Girstmair
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
*/
function generateScript () {
pdfUrl2=pdfUrl.replace(openDlCustName, "");
mycode="#!/bin/bash\nagent=\""+navigator.userAgent+"\"\nmkdir "+ issueDirs[1]+"\n";
var i_y = 1;
for (var i = 1; i < issueDirs.length; i++) {
var i_x = (i<10? "0"+i : i);
if (i>1 && issueDirs[i] != issueDirs[i-1]) {
i_y = 1;
}
mycode+= ("wget "+pdfUrl2 + issueDirs[i] + "/iPad_PDF_"+ i_y +".pdf -U \"${agent}\" -O "+ issueDirs[1] + "/iPad_PDF_"+ i_x +".pdf\n");
i_y++;
}
mycode+="cd "+ issueDirs[1] +"\nfind -size 0|xargs rm\npdfunite * alles.pdf";
return mycode;
};
window.onload = function () {if (confirm('download this issue?')) {
var a = window.document.createElement('a');
a.href = window.URL.createObjectURL(new Blob([generateScript()], {type: 'text/x-shellscript'}));
a.download = 'derstandard-dl.sh';
// Append anchor to body.
document.body.appendChild(a);
a.click();
// Remove anchor from body
document.body.removeChild(a);
}};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment