forked from LenAnderson/Empornium-Quick-Thumbnail-Preview
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathempornium_quick_thumbnail_preview.user.js
610 lines (573 loc) · 24.1 KB
/
empornium_quick_thumbnail_preview.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
// ==UserScript==
// @name Empornium Quick Thumbnail Preview
// @namespace https://github.com/LenAnderson/
// @downloadURL https://github.com/LenAnderson/Empornium-Quick-Thumbnail-Preview/raw/master/empornium_quick_thumbnail_preview.user.js
// @version 0.14
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_registerMenuCommand
// @include *empornium.me/*
// @include *pornbay.org/*
// ==/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 = [
'http://xxx.freeimage.us/image.php?id=AE7D_4F2C0321',
'http://xxx.freeimage.us/image.php?id=F640_4F36C6E1&gif',
'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',
'http://ist1-2.filesor.com/pimpandhost.com/5/9/8/7/59874/X/D/S/g/XDSg/lordzilla_Sign%20Off%20Banner_3_Rounded.jpg',
'http://hostingb.hotchyx.com/adult-image-hosting-th-07/3561cookie-monster-wtf-is-this.jpg',
'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'
];
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);
focus();
}
function loadContainer(that) {
var ttrigger = that;
container.img.className = 'eqtp_hidden';
container.loading.className = '';
picNo = 0;
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) {
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 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 - document.body.parentElement.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 keyUpListener(evt) {
if (evt.ctrlKey) {
switch(evt.keyCode) {
case 39:
nextPage();
break;
case 37:
prevPage();
break;
}
}
if (!visible)
return null;
switch(evt.keyCode) {
case 39:
if (picNo+1 < cache[link]['images'].length) {
picNo++;
loadPic();
}
break;
case 37:
if (picNo > 0) {
picNo--;
loadPic();
}
break;
case 17:
if (GM_getValue('_EQTP_MANUAL_THANKS') == null || GM_getValue('_EQTP_MANUAL_THANKS')) {
sendThanks();
}
break;
case 16:
openPic();
break;
case 46:
downloadTorrent();
break;
case 86:
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() {
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('mouseover', mouseOverListener, false);
trigger.addEventListener('mouseout', mouseOutListener, false);
trigger.addEventListener('click', clickListener, false);
trigger.addEventListener('dblclick', doubleClickListener, false);
getAncestor(trigger, 'div').title = '';
}
document.addEventListener('click', clickAnywhereListener, false);
document.addEventListener('mousemove', mouseMoveListener, false);
document.addEventListener('keyup', keyUpListener, false);
//document.addEventListener('mousewheel', mouseScrollListener, false);
container.img.addEventListener('load', loadListener, 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();
})();