userscripts/zippyshare.js

32 lines
1.1 KiB
JavaScript

// ==UserScript==
// @name Zippyshare
// @description Zippyshare download URL to Wget command
// @version 1.0
// @namespace http://www.adrian.kousz.ch/
// @require https://git.adrian.kousz.ch/adrian/userscripts/raw/master/lib.js
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
// @match http://*.zippyshare.com/*
// @grant none
// ==/UserScript==
AdiUserscriptLib.addButton('Wget Cmd', function () {
var vars = {}
var commandline = 'wget -cO "{name}" --header="Cookie: JSESSIONID={sessioncookie}" {url}\ntouch -d "{date}" "{name}"\n'
var commands = ''
vars.name = $('font:contains("Name: ") + font').text()
vars.url = $('a#dlbutton')[0].href
vars.date = $('font:contains("Uploaded:") + font').text()
vars.sessioncookie = prompt('Session Cookie (is HttpOnly)?')
// Fix date
var datematch = vars.date.match(/^(\d{2})-(\d{2})-(\d{4})(.+)/)
vars.date = AdiUserscriptLib.interpolate('{3}-{2}-{1}{4}', datematch)
commands += AdiUserscriptLib.interpolate(commandline, vars)
var w = window.open();
w.document.write('<pre>' + commands + '</pre>')
w.document.close()
})