Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==UserScript==
// @name dev_emp_prev_th
// @namespace2 unt0uchable
// @description Displays torrent images when cursor hovers over torrent thumbnail (scroll with arrows or wheel). Based on Empornium Quick Thumbnail Preview by LenAnderson (https://github.com/LenAnderson/Empornium-Quick-Thumbnail-Preview).
// @author unt0uchable
// @version 0.99
// @downloadURL https://gist.github.com/unt0uchable/612cf3064d5fd1d51865ed155de5b9b9/raw/fa1bd0cad580d70cb89536c9899c578c7687994d/dev_emp_prev_th.user.js
// @updateURL https://gist.github.com/unt0uchable/612cf3064d5fd1d51865ed155de5b9b9/raw/fa1bd0cad580d70cb89536c9899c578c7687994d/dev_emp_prev_th.user.js
// @include http://torrents.empornium.me/torrents.php*
// @include http://torrents.empornium.me/user.php*
// @include http://torrents.empornium.me/collages.php?id*
// @include http://www.empornium.me/torrents.php*
// @include http://www.empornium.me/user.php*
// @include http://www.empornium.me/collage.php*
// @include http://www.empornium.me/collages.php?id*
// @include http://www.empornium.me/bookmarks.php*
// @include http://pornbay.org/torrents.php*
// @include http://pornbay.org/user.php*
// @include http://torrents.empornium.me/top10.php*
// @grant GM_xmlhttpRequest
// @grant GM_getResourceURL
// @grant GM_getValue
// @grant GM_setValue
// ==/UserScript==
(function() {
var keepVisible = false;
var visible = false;
var pageX = 0;
var pageY = 0;
var cursorOffsetX = 10;
var cursorOffsetY = 5;
var container;
var link;
var id;
var cache = [];
var picNo = 0;
var trigger;
var blacklist = [
// empornium icons
'empornium.me/static/styles/',
// 'empornium.me/static/common/',
'empornium.me/static/common/icons/',
'empornium.me/static/common/smileys/',
'empornium.ph/images/2014/10/17/empornium.png',
'empornium.ph/images/2014/10/18/emp_logo.jpg',
'empornium.sx/images/2014/01/17/emptoplogo1.png',
'empornium.png',
'emp_logo.jpg',
'emptoplogo1.png',
// blackandtan
'empornium.sx/images/2014/06/04/sparkleheader3.png',
'empornium.sx/images/2014/06/04/mrsparkle.png',
'empornium.sx/images/2014/06/04/fileinfo.png',
'empornium.sx/images/2014/06/04/sparklepre2.png',
'empornium.sx/images/2014/06/04/sparkleuploads2.png',
// sandy1312
'http://xxx.freeimage.us/image.php?id=AE7D_4F2C0321',
// lordzilla
'http://ist1-2.filesor.com/pimpandhost.com/5/9/8/7/59874/X/D/S/g/XDSg/lordzilla_Sign%20Off%20Banner_3_Rounded.jpg',
// maxrat
'http://xxx.freeimage.us/image.php?id=3D98_51D7C44D&jpg',
'http://xxx.freeimage.us/image.php?id=3D98_51D7C44D&jpg',
'http://xxx.freeimage.us/image.php?id=BAAC_51D7BCFD&gif',
'http://xxx.freeimage.us/image.php?id=23EC_51D7BCFD&gif',
'http://xxx.freeimage.us/image.php?id=3CB6_51D7BCFD&gif',
'http://xxx.freeimage.us/image.php?id=11CE_51D7BCFD&gif',
'http://xxx.freeimage.us/image.php?id=A37C_4F735C36&gif',
'empornium.ph/images/2014/12/05/signbot6FYCM.gif',
'empornium.me/static/common/smileys/thumbup.gif',
'empornium.sx/images/2014/01/17/emptoplogo1.png',
'http://xxx.freeimage.us/image.php?id=7B66_51D7C61D&jpg',
// thethinwhiteduke
'empornium.sx/images/2015/01/24/06-thin-white-duke-smaller.gif',
'empornium.sx/images/2015/01/24/ScreensBowieuJTNC.gif',
'empornium.sx/images/2015/01/24/ThumbnailDukevc0rw.gif',
'empornium.sx/images/2015/01/27/idkb887b.gif',
'empornium.sx/images/2015/01/24/50093ce9.png',
'http://xxx.freeimage.us/image.php?id=E8A8_53B31227&jpg',
'http://xxx.freeimage.us/image.php?id=C08E_53B32551&jpg',
'http://xxx.freeimage.us/image.php?id=D988_53B330EC&jpg',
// cjc1972
// d3m0nic
'empornium.ph/images/2016/04/17/original_cooltext177616521589692.png',
'empornium.ph/images/2016/04/07/28it14076b.gif',
'empornium.ph/images/2015/11/13/demonrat2.png',
'empornium.ph/images/2015/09/13/cooltext136657496740257.png',
'empornium.ph/images/2015/09/13/cooltext136659143972235.png',
'empornium.ph/images/2015/09/13/cooltext136659375779363.png',
// pi_rat
'empornium.ph/images/2015/11/19/trb-hackedc1c72.png',
'empornium.ph/images/2015/11/19/gf_logo.png',
'empornium.ph/images/2015/11/19/slogan.png',
'empornium.ph/images/2015/12/16/gfrevenge-amateur-teen-sex.jpg',
'empornium.me/static/common/smileys/hmmm.gif',
'empornium.me/static/common/smileys/dunno.gif',
'empornium.ph/images/2015/09/13/thetruthgif.gif',
// locust
'empornium.ph/images/2015/08/29/locust.png',
// lemmesee
'empornium.ph/images/2015/04/16/cast11p2jNF.png',
// usillyboy
'empornium.sx/images/2013/11/29/pinkrat.jpg',
'empornium.sx/images/2014/10/17/SmallEvilRat.gif',
'empornium.me/static/common/smileys/thumbsup.gif',
// sinm
'empornium.ph/jerking/images/2016/05/09/a.png',
'empornium.ph/images/2016/02/27/coollogo_com-50811267.png',
'empornium.ph/images/2016/02/27/coollogo_com-276022197.png',
'empornium.ph/images/2016/02/27/coollogo_com-210004722.png',
'empornium.ph/images/2016/04/08/1.png',
// website banners
'http://ist1-4.filesor.com/pimpandhost.com/1/_/_/_/1/x/7/9/8/x798/ecg1.jpg',
'http://xxx.freeimage.us/image.php?id=49D1_4F3DBD85',
'http://i.imgur.com/HfgqI.jpg',
'http://funkyimg.com/u2/1284/945/846226sig-EMP2.jpg',
'http://xxx.freeimage.us/image.php?id=7183_4F2851AC&jpg',
// other
'http://hostingb.hotchyx.com/adult-image-hosting-th-07/3561cookie-monster-wtf-is-this.jpg',
'http://xxx.freeimage.us/image.php?id=F640_4F36C6E1&gif',
// unresolvable
'http://blackassfest.info/image-share/images/86448733429600273768.png',
'http://blackassfest.info/image-share/images/26006961220243660207.png',
'http://blackassfest.info/image-share/images/89009049707335146654.png',
'http://blackassfest.info/image-share/images/48429454526199578795.png',
'http://blackassfest.info/image-share/images/35849877455159463440.jpg',
// new
'empornium.ph/images/2016/04/30/file-info-icon128.png',
'empornium.ph/images/2016/04/30/screenshots-icon128.png',
'empornium.ph/images/2016/04/30/task-notes-icon128.png'
];
var imgCache = [];
function updatePositions() {
container.style.top = (pageY+container.img.offsetHeight<=window.innerHeight?
pageY+cursorOffsetY :
window.innerHeight-container.img.offsetHeight - 4)+"px";
container.style.left = (pageX+cursorOffsetX)+"px";
container.img.style.maxHeight = (window.innerHeight - 4) + "px";
container.img.style.maxWidth = (window.innerWidth - 4 - (pageX+cursorOffsetX)) + "px";
}
function showContainer() {
visible = true;
container.className = '';
trigger.className = 'eqtp_trigger';
}
function hideContainer() {
visible = false;
container.className = 'eqtp_hidden';
trigger.className = '';
}
function loadPic() {
container.img.className = 'eqtp_hidden';
container.loading.className = '';
updatePositions();
if (cache[link]['imagesc'][picNo%cache[link]['images'].length] !== undefined) {
container.replaceChild(cache[link]['imagesc'][picNo%cache[link]['images'].length], container.img);
container.img = cache[link]['imagesc'][picNo%cache[link]['images'].length];
showPic();
updatePositions();
} else {
var img = container.img.cloneNode(true);
img.addEventListener('load', loadListener, false);
container.replaceChild(img, container.img);
container.img = img;
container.img.src = '';
container.img.src = cache[link]['images'][picNo%cache[link]['images'].length];
cache[link]['imagesc'][picNo%cache[link]['images'].length] = container.img;
}
}
function showPic() {
container.img.className = '';
container.loading.className = 'eqtp_hidden';
}
function getId() {
return link.replace(/^.+id=(\d+).*$/i, '$1');
}
function downloadTorrent() {
if (GM_getValue('_EQTP_AUTO_THANKS') == null || GM_getValue('_EQTP_AUTO_THANKS')) {
sendThanks();
}
if (GM_getValue('_EQTP_AUTO_COMMENT')) {
sendComment();
}
//location.href = "http://torrents.empornium.me/download.php?torrent=" + id;
window.open(dlink);
}
function loadContainer(that) {
var ttrigger = that;
container.img.className = 'eqtp_hidden';
container.loading.className = '';
picNo = 0;
if (document.getElementsByTagName('body')[0].id == 'bookmarks') {
link = getNextSibling(getAncestor(that, 'td'), 'td').getElementsByTagName('a')[0].href;
dlink = getNextSibling(getAncestor(that, 'td'), 'td').getElementsByTagName('a')[0].href;
} else {
link = getNextSibling(getAncestor(that, 'td'), 'td').getElementsByTagName('a')[1].href;
dlink = getNextSibling(getAncestor(that, 'td'), 'td').getElementsByTagName('a')[0].href;
}
var tlink = link;
id = getId();
if (cache[tlink] !== null && cache[tlink] !== undefined) {
loadPic();
return null;
}
var req = new XMLHttpRequest();
req.open('GET', tlink, true);
req.onreadystatechange = function() {
if (req.readyState != 4)
return null;
var div = document.createElement('div');
div.innerHTML = req.responseText;
var divs = div.getElementsByTagName('div');
var desc;
for (var i=0;i<divs.length;i++) {
if (divs[i].id.toLowerCase() == 'descbox') {
desc = divs[i];
}
}
cache[tlink] = [];
cache[tlink]['description_raw'] = desc?desc.innerHTML:'';
cache[tlink]['images'] = [];
cache[tlink]['imagesc'] = [];
cache[tlink]['imglinks'] = [];
cache[tlink]['auth'] = div.querySelector('input[name="auth"]').value;
if (desc) {
var imgs = desc.getElementsByTagName('img');
for (var i=0;i<imgs.length;i++) {
//if (imgs[i].src.search(/^http:\/\/torrents.empornium.me\//i) == -1 && blacklist.indexOf(imgs[i].src) == -1 && cache[tlink]['images'].indexOf(imgs[i].src) == -1) {
// if (imgs[i].src.search(/^http:\/\/torrents.empornium.me\//i) == -1 && (new RegExp(blacklist.join("|")).test(imgs[i].src)) == 0 && cache[tlink]['images'].indexOf(imgs[i].src) == -1) {
if (imgs[i].src.search(/^http:\/\/torrents.empornium.me\//i) == -1 && (blacklist.some(function(v) { return imgs[i].src.indexOf(v) >= 0; })) == 0 && cache[tlink]['images'].indexOf(imgs[i].src) == -1) {
cache[tlink]['images'].push(resolveImgURL(imgs[i].src));
cache[tlink]['imglinks'].push(resolveImgLink(imgs[i]));
}
}
}
if (cache[tlink]['images'].length == 0) {
cache[tlink]['images'].push('data:image/gif;base64,R0lGODlhQABAAPf/ADMzM////5mZmQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAQABAAAAI/wADCBxIsKDBgwgTKlzIsKHDhwoFSJxIsaLFixgzaqxIUADEjyAPehw4MqTJjyUDpDzJcmHKlS1jGnwps6bIjjZzksSpMyfNnjZ/ApUpdGjLokZPIk0acilTlDyfmnQq1SHVqgyvYo0YdetDrV5v7gz7tStZl2bPJgTLEEBBt0HTfgQAV2BdonIhuq0Ll67fuxDZLuxrt/BAwGXHnuQbgPDhqXkf3qVruDJUxSYB9/2L2GpktV1hEuRMlm3nqqZHc/Zrl3Rj16sRpn5cubNjw5Nlf7bMGDfs0a3/6saMMHdt3sgbN9T6+/hr4c9ZR6csVqDopKeHW38aO/F20GiJgzefuRu8YLXnz6YvXR70+rDvvcbfOh9rfdTt0edXv5+9+PGhAbhWf/ARKF9HGyWo4IIZCeigTgEBADs=');
}
if (link == tlink) {
loadPic();
}
};
req.send(null);
}
function openDetails() {
location.href = link;
}
function openPic() {
//window.open(cache[link]['images'][picNo%cache[link]['images'].length]);
window.open(cache[link]['imglinks'][picNo%cache[link]['images'].length]);
}
function sendThanks() {
var auth = cache[link]['auth'];
var req = new XMLHttpRequest();
//req.open('POST', 'http://torrents.empornium.me/torrents.php?action=thank', true);
req.open('POST', '/torrents.php?action=thank', true);
req.onreadystatechange = function() {
if (req.readyState != 4)
return null;
container.thanks.className = '';
window.setTimeout(function() { container.thanks.className = 'eqtp_hidden'; }, 2000);
};
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.send('groupid='+id+'&action=thank&auth='+auth);
}
function sendComment() {
var comments = GM_getValue('_EQTP_AUTO_COMMENT_MESSAGE').split('|');
var comment = comments[Math.floor(Math.random()*comments.length)];
var auth = cache[link]['auth'];
var req = new XMLHttpRequest();
req.open('POST', '/torrents.php?id='+id, true);
req.onreadystatechange = function() {
if (req.readyState != 4)
return null;
container.thanks.className = '';
window.setTimeout(function() { container.thanks.className = 'eqtp_hidden'; }, 2000);
};
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.send('action=reply&auth='+auth+'&groupid='+id+'&body='+encodeURIComponent(comment));
}
function nextPage() {
console.info('1');
if (location.href.search(/page=\d+/i) > -1) {
var page = location.href.replace(/.+page=(\d+).*/i, '$1');
page++;
location.href = location.href.replace(/page=\d+/i, 'page=' + page);
} else {
location.href = location.href.replace(/torrents.php\??/i, 'torrents.php?page=2&');
}
}
function prevPage() {
if (location.href.search(/page=\d+/i) > -1) {
var page = location.href.replace(/.+page=(\d+).*/i, '$1');
page--;
if (page >= 0)
location.href = location.href.replace(/page=\d+/i, 'page=' + page);
}
}
function markVisited(evt) {
var tag = evt.target.tagName.toLowerCase();
if (tag != 'input' && tag != 'textarea' && tag != 'select') {
evt.preventDefault();
var href = location.href;
history.replaceState({},"",link);
history.replaceState({},"",href);
}
}
/* ##################################################################
* LISTENERS
* ##################################################################
*/
// function onLoadListener(evt) {
// if (keepVisible)
// return null;
// trigger = this;
// showContainer();
// loadContainer(this);
// }
function mouseOverListener(evt) {
if (keepVisible)
return null;
trigger = this;
showContainer();
loadContainer(this);
}
function mouseOutListener(evt) {
if (keepVisible)
return null;
hideContainer();
}
function clickListener(evt) {
evt.preventDefault();
evt.stopPropagation();
keepVisible = !keepVisible;
}
function clickAnywhereListener(evt) {
if (!keepVisible)
return null;
evt.preventDefault();
evt.stopPropagation();
keepVisible = false;
hideContainer();
}
function doubleClickListener(evt) {
openDetails();
}
function mouseMoveListener(evt) {
if (keepVisible)
return null;
pageX = evt.pageX;
pageY = evt.pageY - document.body.scrollTop;
updatePositions();
}
function mouseScrollListener(evt) {
if (!visible)
return null;
evt.preventDefault();
if (evt.wheelDeltaY > 0)
picNo++;
if (evt.wheelDeltaY < 0 && picNo > 0)
picNo--;
loadPic();
}
function mouseWheelListener(evt) {
if (!visible)
return null;
evt.preventDefault();
// cross-browser wheel delta
var evt = window.event || evt; // old IE support
var delta = Math.max(-1, Math.min(1, (evt.wheelDelta || -evt.detail)));
if (delta > 0 && picNo > 0)
picNo--;
if (delta < 0 && picNo+1 < cache[link]['images'].length)
picNo++;
loadPic();
// myimage.style.width = Math.max(50, Math.min(800, myimage.width + (30 * delta))) + "px";
// return false;
}
// if (!visible)
// return null;
// evt.preventDefault();
// if (evt.wheelDeltaY > 0)
// picNo++;
// if (evt.wheelDeltaY < 0 && picNo > 0)
// picNo--;
// loadPic();
// }
function keyUpListener(evt) {
if (evt.ctrlKey) {
switch(evt.keyCode) {
case 39: // right
nextPage();
break;
case 37: // left
prevPage();
break;
}
}
if (!visible)
return null;
switch(evt.keyCode) {
case 39: // right
if (picNo+1 < cache[link]['images'].length) {
picNo++;
loadPic();
}
else {
// comment out to disable wraparound image display
pinNo = 0;
loadPic();
}
if (picNo == 2 || cache[link]['images'].length == 1) {
// mark visited whenever a 2nd image is displayed
markVisited(evt);
}
break;
case 37: // left
if (picNo > 0) {
picNo--;
loadPic();
}
else {
// comment out to disable wraparound image display
pinNo = cache[link]['images'].length-1;
loadPic();
}
if (picNo == cache[link]['images'].length-1 || cache[link]['images'].length == 1) {
// mark visited whenever a 2nd image is displayed
markVisited(evt);
}
break;
case 17: // ctrl
if (GM_getValue('_EQTP_MANUAL_THANKS') == null || GM_getValue('_EQTP_MANUAL_THANKS')) {
sendThanks();
}
break;
case 16: // shift
openPic();
break;
case 46: // delete
downloadTorrent();
break;
case 86: // v
markVisited(evt);
break;
}
}
function loadListener(evt) {
showPic();
updatePositions();
}
/* ##################################################################
* /LISTENERS
* ##################################################################
*/
/* ##################################################################
* IMG-HOSTS
* ##################################################################
*/
function buildImgProxyUrl(phost, purl, preferer) {
return 'http://eqtp.cwsurf.de/imghost.php?host=' + phost + '&url=' + purl + '&referer=' + preferer;
}
function resolveImgURL(url) {
var host = resolveImgHost(url);
if (host === null)
return url;
return host(url);
}
function resolveImgLink(img) {
var el = getAncestor(img, 'a');
if (el === null) return img.src;
return el.href;
}
function resolveImgHost(url) {
if (url.search(/^http:\/\/xxx.freeimage.us\/thumb.php\?id=/i) == 0)
return resolveFreeimage;
if (url.search(/funkyimg\.com\/t\d+\//i) > -1)
return resolveFunkyimg;
//if (url.search(/t\d+\.imgchili\.com/i) > -1)
// return resolveImgchili;
if (url.search(/yourfreeporn\.us.+\d+small\.jpg$/i) > -1)
return resolveYourfreeporn;
//if (url.search(/img\d+\.imagetwist\.com\/th\//i) > -1)
// return resolveImagetwist;
if (url.search(/^http:\/\/s\d+\.bo\.lt\/.+asset:version=\d+\/thumb_.+\.jpg$/i) > -1)
return resolveBolt;
//if (url.search(/thumb\.dumparump\.com/i) > -1)
// return resolveDumparump;
//if (url.search(/img\d+\.piclambo\.net.+_t\.jpg$/i) > -1)
// return resolvePiclambo;
return null;
}
function resolveFreeimage(url) {
return url.replace(/^(http:\/\/xxx.freeimage.us\/)thumb(.php\?id=.+)$/i, '$1image$2');
}
function resolveFunkyimg(url) {
return url.replace(/\/t(\d+)\//i, '/u$1/');
}
function resolveImgchili(url) {
var phost = url.replace(/^http:\/\/t(\d+)\..+$/i, 'i$1.imgchili.com');
var purl = url.replace(/^http:\/\/t\d+\.imgchili\.com(\/.+)$/i, '$1');
var preferer = 'http://imgchili.com/show' + purl;
return buildImgProxyUrl(phost, purl, preferer);
}
function resolveYourfreeporn(url) {
return url.replace(/(\d+)small\.jpg$/i, '$1.jpg');
}
function resolveImagetwist(url) {
/*'http://img4.imagetwist.com/i/01013/2p6yl2cimykc.jpg'
"http://img4.imagetwist.com/i/01013/2p6yl2cimykc.jpg"
'http://imagetwist.com/2p6yl2cimykc/FAE73TE.jpg.html'
"http://imagetwist.com/2p6yl2cimykc/FAE73TE.jpg.html"
'http://img4.imagetwist.com/th/01013/2p6yl2cimykc.jpg'*/
var phost = url.replace(/^http:\/\/(img\d+\.imagetwist\.com).+$/i, '$1');
var purl = url.replace(/^http:\/\/img\d+\.imagetwist\.com\/th\/(.+)$/i, '/i/$1');
var preferer = url.replace(/^http:\/\/img\d+\.imagetwist\.com\/th\/[^\/]+\/(.+)\.jpg$/i, 'http://imagetwist.com/$1/');
return buildImgProxyUrl(phost, purl, preferer);
}
function resolveBolt(url) {
return url.replace(/^(http:\/\/s\d+\.bo\.lt\/.+asset:version=\d+\/)thumb_(.+\.jpg)$/i, '$1$2');
}
function resolveDumparump(url) {
var phost = 'image.dumparump.com';
var purl = url.replace(/^http:\/\/thumb\.dumparump\.com/i, '');
var preferer = url.replace(/thumb\.dumparump\.com\/\d+\/(.+)\.jpg$/i, 'www.dumparump.com/view.php?id=$1');
return buildImgProxyUrl(phost, purl, preferer);
}
function resolvePiclambo(url) {
var phost = url.replace(/http:\/\/(img\d+\.)piclambo\.net.+$/i, '$1imageporter.com');
var purl = url.replace(/(img\d+\.)piclambo\.net(.+)_t\.jpg$/i, '$1imageporter.com$2.jpg');
var preferer = url.replace(/img\d+\.piclambo\.net\/i\/\d+\/(.+)_t\.jpg/i, 'piclambo.net/$1/.html');
return buildImgProxyUrl(phost, purl, preferer);
}
/* ##################################################################
* /IMG-HOSTS
* ##################################################################
*/
/* ##################################################################
* MENU-COMMANDS
* ##################################################################
*/
function toggleAutoThanks() {
var temp = !GM_getValue('_EQTP_AUTO_THANKS');
GM_setValue('_EQTP_AUTO_THANKS', temp);
alert(temp?
'You will now automatically thank the uploader when you download a torrent with Empornium Quick Thumbnail Preview.' :
'You will no longer automatically thank the uploader when you download a torrent with Empornium Quick Thumbnail Preview.');
}
function toggleManualThanks() {
var temp = GM_getValue('_EQTP_MANUAL_THANKS');
if (temp == null) temp = false;
else temp = !temp;
GM_setValue('_EQTP_MANUAL_THANKS', temp);
alert(temp?
'You can now use your [CTRL] key to send thanks to the uploader.' :
'You can no longer use your [CTRL] key to send thanks to the uploader.');
}
function toggleAutoComment() {
var temp = !GM_getValue('_EQTP_AUTO_COMMENT');
GM_setValue('_EQTP_AUTO_COMMENT', temp);
var msg = temp?
'You will now automatically leave a comment when you download a torrent with Empornium Quick Thumbnail Preview.' :
'You will no longer automatically leave a comment when you download a torrent with Empornium Quick Thumbnail Preview.';
if (!temp) {
alert(msg);
return null;
}
msg += "\n\n";
var comments = GM_getValue('_EQTP_AUTO_COMMENT_MESSAGE');
if (comments.trim() != "")
comments = comments.split("|");
else
comments = array("Thank you!");
if (comments.length == 1)
msg += "Your comment will be:\n";
else
msg += "Your comment will be one of the following:\n";
for (var i=0;i<comments.length;i++) {
msg += "\t" + comments[i] + "\n";
}
alert(msg);
}
function editAutoComment() {
var temp = GM_getValue('_EQTP_AUTO_COMMENT_MESSAGE');
temp = prompt("Please enter your comment.\nYou can enter several comments to be posted randomly by seperating them with |", temp);
GM_setValue('_EQTP_AUTO_COMMENT_MESSAGE', temp);
}
/* ##################################################################
* /MENU-COMMANDS
* ##################################################################
*/
/* ##################################################################
* HELPERS
* ##################################################################
*/
function getAncestor(node, tagName) {
if (node === null || node === undefined)
return null;
var el = node.parentNode;
while (el !== null && el !== undefined && (el.tagName === null || el.tagName === undefined ||
el.tagName.toLowerCase() != tagName.toLowerCase()))
el = el.parentNode;
if (el === null || el === undefined)
return null;
else return el;
}
function getNextSibling(node, tagName) {
if (node === null || node === undefined)
return null;
var el = node.nextSibling;
while (el !== null && el !== undefined && (el.tagName === null || el.tagName === undefined ||
el.tagName.toLowerCase() != tagName.toLowerCase()))
el = el.nextSibling;
if (el === null || el === undefined)
return null;
else return el;
}
/* ##################################################################
* /HELPERS
* ##################################################################
*/
/* ##################################################################
* INIT
* ##################################################################
*/
function initListeners() {
if (document.getElementsByTagName('body')[0].id == 'collage') {
// if (document.getElementsByClassName('torrent_table')[0].id == 'discog_table') {
var trs = document.getElementsByClassName('torrent_table')[0].getElementsByClassName('center');
} else if (document.getElementsByTagName('body')[0].id == 'bookmarks') {
var trs = document.getElementsByClassName('torrent_table')[0].getElementsByClassName('center');
} else {
var trs = document.getElementsByClassName('cats_col');
}
for (var i=0;i<trs.length;i++) {
var trigger = trs[i].getElementsByTagName('img')[0];
if (!trigger) continue;
// trigger.addEventListener('onload', onLoadListener, false);
trigger.addEventListener('mouseover', mouseOverListener, false);
trigger.addEventListener('mouseout', mouseOutListener, false);
trigger.addEventListener('click', clickListener, false);
trigger.addEventListener('dblclick', doubleClickListener, false);
// IE9, Chrome, Safari, Opera
// trigger.addEventListener("mousewheel", MouseWheelHandler, false);
// Firefox
// trigger.addEventListener("DOMMouseScroll", mouseWheelListener, false);
// trigger.addEventListener("DOMMouseScroll", mouseScrollListener, false);
// trigger = trs[i].getElementsByTagName('a')[3];
// trigger.addEventListener('mouseover', mouseOverListener, false);
// trigger.addEventListener('mouseout', mouseOutListener, false);
// trigger.addEventListener('click', clickListener, false);
// trigger.addEventListener('dblclick', doubleClickListener, false);
// trigger = trs[i].getElementsByTagName('img')[0];
if (document.getElementsByTagName('body')[0].id == 'bookmarks') {
trigger.alt = '';
} else {
getAncestor(trigger, 'div').title = '';
}
}
document.addEventListener('click', clickAnywhereListener, false);
document.addEventListener('mousemove', mouseMoveListener, false);
document.addEventListener('keyup', keyUpListener, false);
// document.addEventListener('mousewheel', mouseScrollListener, false);
document.addEventListener("DOMMouseScroll", mouseWheelListener, false);
// document.addEventListener("DOMMouseScroll", mouseScrollListener, false);
container.img.addEventListener('load', loadListener, false);
// container.img.addEventListener('scroll', scrollListener, false);
// container.img.addEventListener('wheel', wheelListener, false);
}
function initMenuCommands() {
GM_registerMenuCommand('[EQTP] Toggle auto-thanks', toggleAutoThanks);
GM_registerMenuCommand('[EQTP] Toggle manual-thanks', toggleManualThanks);
GM_registerMenuCommand('[EQTP] Toggle auto-comment', toggleAutoComment);
GM_registerMenuCommand('[EQTP] Edit auto-comment', editAutoComment);
}
function initGUI() {
container = document.createElement('div');
container.id = 'eqtp_container';
container.className = 'eqtp_hidden';
document.body.appendChild(container);
var img = document.createElement('img');
container.img = img;
container.appendChild(img);
var thanks = document.createElement('p');
thanks.innerHTML = 'Thanks for the thanks!';
thanks.id = 'eqtp_thanks';
thanks.className = 'eqtp_hidden';
container.thanks = thanks;
container.appendChild(thanks);
var loading = document.createElement('span');
loading.innerHTML = 'Loading...';
loading.className = 'eqtp_hidden';
container.loading = loading;
container.appendChild(loading);
}
function initStyle() {
var style = document.createElement('style');
style.innerHTML = '\
#eqtp_container {\
position: fixed;\
border: 2px solid black;\
background: white;\
z-index: 1000;\
}\
\
.eqtp_hidden {\
display: none;\
}\
#eqtp_container > img {\
max-height: 100%;\
max-width: 100%;\
}\
\
#eqtp_thanks {\
font-size: 20px;\
font-weight: bold;\
color: silver;\
position: absolute;\
top: 0;\
left: 0;\
width: 100%;\
background: rgba(0,0,0,0.5);\
}\
\
.torrent_table a img.eqtp_trigger {\
border: 5px solid rgba(2, 97, 163, 1);\
width: 40px;\
height: 40px;\
}';
document.body.appendChild(style);
}
function init() {
initStyle();
initGUI();
initListeners();
initMenuCommands();
// console.info(GM_getValue('_EQTP_AUTO_COMMENT'));
// console.info(GM_getValue('_EQTP_AUTO_COMMENT_MESSAGE'));
// console.info(GM_getValue('_EQTP_AUTO_THANKS'));
}
/* ##################################################################
* /INIT
* ##################################################################
*/
init();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment