Skip to content

Instantly share code, notes, and snippets.

@dvingerh
Last active March 30, 2018 16:06
Show Gist options
  • Save dvingerh/40cc7ae5e18a8d98c07f5b504aad8e6e to your computer and use it in GitHub Desktop.
Save dvingerh/40cc7ae5e18a8d98c07f5b504aad8e6e to your computer and use it in GitHub Desktop.
Add download links and a batch download button for PixHost and ImgBox on Picturepub. Useful if the photos aren't added to an album.
// ==UserScript==
// @name PicturePub Batch Downloader
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Add download links and a batch download button for PixHost and ImgBox on Picturepub. Useful if the photos aren't added to an album.
// @author You
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @match *.pixhost.to/images/*
// @include *picturepub.net/index.php?threads*
// @grant none
// @run-at document-idle
// ==/UserScript==
this.$ = this.jQuery = jQuery.noConflict(true);
$(function() {
if (window.location.hash == "#download" && window.location.href.indexOf(".pixhost.to/images/")) {
$("body").append('<a id="#downloadlink" href="' + window.location.href.split('/')[0] + '" download>Download</a>');
$("body").find("a")[0].click();
setTimeout(function(){window.close(); }, 1000);
}
});
$("blockquote[class^='messageText']").each(function()
{
var count = 0;
var width, widthHalf, dlButton;
$(this).find('a').each(function(){
$(this).find('img').each(function(a){
var src = $(this).attr('src');
if (src.indexOf("pixhost") !== -1)
{
//console.log(src);
//console.log(count);
src = src.replace("/thumbs/", "/images/").replace("//t", "//img");
width = $(this).width() - 25;
widthHalf = (width / 2) + 3;
dlButton = '<a target="_blank" class="dlPixHost" href="' + src + '" style="position: relative; margin-left: -' + (width + 25) + 'px; margin-right: 0px; padding-left: ' + widthHalf + 'px; padding-right:' + (widthHalf + 1) + 'px; background-color: rgba(0,0,0,0.7); font-weight: bold;" download>DL</a>';
$(this).parent().after(dlButton);
count++;
}
});
});
$(this).parent().parent().parent().find("div.privateControls").after('<a style="margin-left: 5px;" href="javascript:void()" class="BatchDl-1 OverlayTrigger item control" data-cacheoverlay="false" style=""><span></span>Batch Download PixHost (' + count + ' Pictures)</a>');
$($(this).parent().parent().parent().find("div.privateControls")).after('<iframe src="https://google.com" frameborder="0" scrolling="no"; style="width: 0px; height: 0px; display: none;" id="dl_iFrame"></iframe>');
});
$("a[class^='BatchDl']").click( function(e) {e.preventDefault(); BatchDownload(this); return false; } );
function BatchDownload(button)
{
var counter = 0;
$($(button).parent().prev().prev().find('a.dlPixHost')).each(function(){
var new_win = window.open($(this).attr('href') + "#download" ,"_blank",'PopUp'+ counter++ +'…', 'toolbar=no, location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=350,height=250,visible=none');
new_win.resizeTo(250, 250);
new_win.moveTo(100, 100);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment