Last active
February 11, 2016 10:19
-
-
Save kyktommy/7444722 to your computer and use it in GitHub Desktop.
itpub file download js bookmarklet
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
javascript:(function() { | |
var $ = jQuery, | |
div = $('<div>').css({'position': 'fixed', 'width': '500px', 'left': '30%', 'top': '10%', 'background': 'red', 'padding': '20px'}), | |
ul = $('<ol>'), | |
cancel = $('<a>').addClass('.cancel').attr('href', '#').css({'float': 'right'}).text('X'); | |
cancel.appendTo(div); | |
div.append(ul); | |
$('body').append(div); | |
var data = []; | |
var links = $('span[id^=attach_] a, .attnm a'); | |
$.each(links, function(i, d) { | |
var id = $(this).attr('href').match(/aid=(.*)&/)[1], | |
fid = $(this).attr('href').match(/fid=(.*)/)[1], | |
_url = 'http://www.itpub.net/forum.php?mod=attachment&aid=' + id + '==&fid=' + fid, | |
_title = $(this).text(); | |
data.push({title: _title, url: _url}); | |
}); | |
if (data == []) { ul.html(''); div.html('no files detected'); } | |
$.each(data, function(i, d) { | |
var a = $('<a>').attr('href', d.url).text(d.title).css({ 'font-size': '18px'}), | |
li = $('<li>'); | |
li.append(a); | |
ul.append(li); | |
}); | |
cancel.bind('click', function(e) { | |
div.hide(); | |
e.preventDefault(); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use this to generate js bookmarklet, then drag it into bookmark bar.
http://ted.mielczarek.org/code/mozilla/bookmarklet.html