Skip to content

Instantly share code, notes, and snippets.

@kyktommy
Last active February 11, 2016 10:19
Show Gist options
  • Save kyktommy/7444722 to your computer and use it in GitHub Desktop.
Save kyktommy/7444722 to your computer and use it in GitHub Desktop.
itpub file download js bookmarklet
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();
});
})();
@kyktommy
Copy link
Author

Use this to generate js bookmarklet, then drag it into bookmark bar.
http://ted.mielczarek.org/code/mozilla/bookmarklet.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment