Fix lib: interpolate globally, Add some hosters
This commit is contained in:
parent
d977f53036
commit
62ca61246b
4 changed files with 62 additions and 3 deletions
25
hulkshare.js
Normal file
25
hulkshare.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
// ==UserScript==
|
||||
// @name HulkShare
|
||||
// @description HulkShare download URL to Wget command
|
||||
// @version 1.0
|
||||
// @namespace http://www.adrian.kousz.ch/
|
||||
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
|
||||
// @match http://*.hulkshare.com/*
|
||||
// @grant none
|
||||
// ==/UserScript==
|
||||
|
||||
AdiUserscriptLib.addButton('Wget Cmd', function () {
|
||||
var vars = {}
|
||||
var commandline = 'wget -cO "{name}" --referer="{ref}" {url}'
|
||||
var commands = ''
|
||||
|
||||
vars.name = $('b.nhsTrackTitle').text()
|
||||
vars.url = $('button.nhsGrayBtnSmDownload').attr('href')
|
||||
vars.ref = window.location.href
|
||||
|
||||
commands += AdiUserscriptLib.interpolate(commandline, vars) + '\n'
|
||||
|
||||
var w = window.open();
|
||||
w.document.write('<pre>' + commands + '</pre>')
|
||||
w.document.close()
|
||||
})
|
7
lib.js
7
lib.js
|
@ -1,7 +1,12 @@
|
|||
AdiUserscriptLib = {}
|
||||
|
||||
AdiUserscriptLib.interpolate = function (s, a) {
|
||||
for (x in a) s = s.replace('{' + x + '}', a[x])
|
||||
// Oh, well... http://stackoverflow.com/a/16804092
|
||||
for (x in a) {
|
||||
var token = '{' + x + '}'
|
||||
var i = 0
|
||||
while ( (i = s.indexOf(token, i)) >= 0) s = s.replace(token, a[x])
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ AdiUserscriptLib.addButton('Wget Cmds', function () {
|
|||
var commands = ''
|
||||
|
||||
$('a.podcast-title').each(function () {
|
||||
var divlinks = this.nextElementSibling.nextElementSibling
|
||||
vars.url = $(divlinks).children('a:contains(Download)').attr('href')
|
||||
divlinks = $(this).nextUntil('div.links').next()
|
||||
vars.url = divlinks.find('a:contains("Download")').attr('href')
|
||||
vars.name = $(this).text()
|
||||
commands += AdiUserscriptLib.interpolate(commandline, vars) + '\n'
|
||||
})
|
||||
|
|
29
zippyshare.js
Normal file
29
zippyshare.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
// ==UserScript==
|
||||
// @name Zippyshare
|
||||
// @description Zippyshare download URL to Wget command (set $COOKIE manually)
|
||||
// @version 1.0
|
||||
// @namespace http://www.adrian.kousz.ch/
|
||||
// @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=$COOKIE" {url}; touch -d "{date}" "{name}"'
|
||||
var commands = ''
|
||||
|
||||
vars.name = $('font:contains("Name: ") + font').text()
|
||||
vars.url = $('a#dlbutton')[0].href
|
||||
vars.date = $('font:contains("Uploaded:") + font').text()
|
||||
|
||||
// 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) + '\n'
|
||||
|
||||
var w = window.open();
|
||||
w.document.write('<pre>' + commands + '</pre>')
|
||||
w.document.close()
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue