-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhfr_smart_auto_r_mod_r21.user.txt
More file actions
575 lines (513 loc) · 24.5 KB
/
Copy pathhfr_smart_auto_r_mod_r21.user.txt
File metadata and controls
575 lines (513 loc) · 24.5 KB
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
// ==UserScript==
// @name [HFR] Smart Auto Rehost
// @version 4.0.6
// @namespace http://mycrub.info
// @description Rehost automatiquement (sur hfr-rehost.net) les images provenant d'une liste de sites donnés
// @include http://forum.hardware.fr/*
// ==/UserScript==
var img, src;
var rehost = GM_getValue("ar_rehost_site", "http://hfr-rehost.net/");
function processNode(node) {
var cmpt = 0;
var toRehost = getRehostableRegExps();
var startTime = new Date().valueOf();
var imgs = node.getElementsByTagName('img');
for (var i = 0; i < imgs.length; ++i) {
img = imgs[i];
src = img.getAttribute('src');
for (var j = 0; j < toRehost.length; j++) {
if (src && (src.match(toRehost[j]))) {
img.setAttribute('src', rehost + src);
img.setAttribute('alt', 'Rehosted: '+ src);
img.setAttribute('title', 'Rehosted: ' + src);
cmpt++;
}
}
}
GM_log(cmpt + " images en " + (new Date().valueOf() - startTime) + " ms");
}
function getRehostableRegExps() {
var rehostables = getCurrentRehostables().split("\n");
var result = [];
for (var i = 0; i < rehostables.length; i++) {
if (rehostables[i] && rehostables[i].length>0) {
result[result.length] = '^http://([^/:])*' + rehostables[i] + '/.*';
}
}
return result;
}
var getElementByXpath = function (path, element)
{
var arr = Array(), xpr = document.evaluate(path, element, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
for (;item = xpr.iterateNext();) arr.push(item);
return arr;
}
var cssManager =
{
cssContent : '',
addCssProperties : function (properties)
{
cssManager.cssContent += properties;
},
insertStyle : function()
{
GM_addStyle(cssManager.cssContent);
cssManager.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P//2YA/2Yz/2Zm/2aZ/2bM/2b//5kA/5kz/5lm/5mZ/5nM/5n//8wA/8wz/8xm/8yZ/8zM/8z///8A//8z//9m//+Z///M////RGKwUAAAAAF0Uk5TAEDm2GYAAAABYktHRACIBR1IAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH2QYQCDgpfYIwVwAAAKJJREFUGNN10DEOwyAMBdBIHXo/OvUisOC74C5JlpyiWcBdwj1KF8ga22nVdsiXkNCTsWW67jA35Aw/AJg4jSj/QSm1tXed8yHFWJSy2ugw3IVqbeuqBBbnOcWnFi0gdHEoVmJphBayEqD2D54DD6azMXL31vKhLDReh2nqvfF46pes1AGAD/KU++8ThfZm9UWflRzPxDklRPru7ByPpeNP2QA+xXyJjelK2QAAAABJRU5ErkJggg==");
}
function getCurrentRehostables() {
return GM_getValue("ar_rehost_hostnames", "xs.to\nebaumsworld.com\nexplosm.net\ntinypic.com\nthreadbombing.com\nnoelshack.com\nggpht.com\nmyspacecdn.com\nmegaportail.com\nimagup.com\nxkcd.com\nskyrock.com\nytmnd.com\ni.pbase.com\nencyclopediadramatica.com\nlivejournal.com\nmuchosucko.com\ntinypic.com\nmoviesmedia.ign.com\ndvdrama.com\nsmugmug.com\nimagup.com\nhotflick.net\nchickencrap.com\nkoreus.com\nworldofwarcraft.com\njeuxvideo.com\njoystiq.com\nstereomaker.net\nimageshack.us\nwordpress.com\nbouletcorp.com\ndeviantart.com\nnofrag.com\nalkaspace.com\njj.am\ninexes.com\nmmo-champion.com\nlolpix.com\ngiftube.com\nflickr.com\nfacebook.com\nphotobucket.com\nnnm.ru\nse7en.ru\nb3ta.com\nimagehaven.net\nzimagez.com\nafrojacks.com\ncanardpc.com\ngopix.fr\njudgehype.com\nfohguild.org\nno-ip.org\narchive-host.com\nlelombrik.net\nhaluze.sk\nhostingpics.net\nfbcdn.net\nseries-80.net\ndrugs-plaza.com\nfree.fr\ndynamictic.info\nratemyeverything.net\nsmog.pl\nuppix.net\necho.cx\ntuxboard.com\nhumour.com\nmac.com\ntbn..google.com\n4gifs.com\nleboncoin.fr");
}
function getCurrentBl() {
return GM_getValue("ar_bl_hostnames", "hardware.fr\nhfr-rehost.net");
}
var hostRegExp = new RegExp("^http://([^/]*\\.)*([^\\./]+\\.[^\./]+)/.*", "i");
function getHostname(url) {
var ex = hostRegExp.exec(url);
return (ex && ex.length > 0) ? ex[2] : null;
}
function resetHostnames() {
GM_setValue("ar_rehost_hostnames", "xs.to;ebaumsworld.com;explosm.net;tinypic.com;threadbombing.com;noelshack.com;ggpht.com;myspacecdn.com;megaportail.com;imagup.com;xkcd.com;skyrock.com;ytmnd.com;i.pbase.com;encyclopediadramatica.com;livejournal.com;muchosucko.com;tinypic.com;moviesmedia.ign.com;dvdrama.com;smugmug.com;imagup.com;hotflick.net;chickencrap.com;koreus.com;worldofwarcraft.com;jeuxvideo.com;joystiq.com;stereomaker.net;imageshack.us;wordpress.com;bouletcorp.com;deviantart.com;nofrag.com;alkaspace.com;jj.am;inexes.com;mmo-champion.com;lolpix.com;giftube.com;flickr.com;facebook.com;photobucket.com;nnm.ru;se7en.ru;b3ta.com;imagehaven.net;zimagez.com;afrojacks.com;canardpc.com;gopix.fr;judgehype.com;fohguild.org;no-ip.org;archive-host.com;lelombrik.net;haluze.sk;hostingpics.net;fbcdn.net;series-80.net;drugs-plaza.com;free.fr;dynamictic.info;ratemyeverything.net;smog.pl;uppix.net;echo.cx;tuxboard.com;humour.com;mac.com;tbn..google.com;4gifs.com;leboncoin.fr");
}
function addHostname() {
var newHostname = prompt("Ajouter un nom de domaine (et tous ses sous-domaines) à rehoster.\nExemple : imageshack.us");
if (newHostname && newHostname.length > 0) {
GM_setValue("ar_rehost_hostnames", getCurrentRehostables() + ";" + newHostname);
}
}
function blHostname() {
var bl = prompt("Liste des noms de domaine à ne JAMAIS rehoster (séparateur ';')\nExemple : hardware.fr;hfr-rehost.net", GM_getValue("blHostnames", ""));
if (bl) {
GM_setValue("ar_bl_hostnames", bl);
}
}
function debug() {
var hn = prompt("Liste des noms de domaine à rehoster (séparateur ';')\nExemple : imageshack.us;imagup.com", GM_getValue("hostnames", ""));
if (hn) {
GM_setValue("ar_rehost_hostnames", hn);
}
}
// **********************************************
// Commandes de menu
// **********************************************
//GM_registerMenuCommand("[HFR] Auto Rehost -> Reset", this.resetHostnames);
//GM_registerMenuCommand("[HFR] Auto Rehost -> Ajouter un nom de domaine", this.addHostname);
//GM_registerMenuCommand("[HFR] Auto Rehost -> Ne pas rehoster", this.blHostname);
//GM_registerMenuCommand("[HFR] Auto Rehost -> Debug", this.debug);
var cmScript =
{
backgroundDiv : null,
configDiv : null,
timer : null,
setDivsPosition : function ()
{
cmScript.setBackgroundPosition();
cmScript.setConfigWindowPosition();
},
setBackgroundPosition : function ()
{
cmScript.backgroundDiv.style.width = document.documentElement.clientWidth + 'px';
cmScript.backgroundDiv.style.height = document.documentElement.clientHeight + 'px';
cmScript.backgroundDiv.style.top = window.scrollY + 'px';
},
setConfigWindowPosition : function ()
{
cmScript.configDiv.style.left = (document.documentElement.clientWidth / 2) - (parseInt(cmScript.configDiv.style.width) / 2) + window.scrollX + 'px';
cmScript.configDiv.style.top = (document.documentElement.clientHeight / 2) - (parseInt(cmScript.configDiv.clientHeight) / 2) + window.scrollY + 'px';
},
disableKeys : function (event)
{
var key = event.which;
if (key == 27)
{
clearInterval(cmScript.timer);
cmScript.hideConfigWindow();
}
//else if (key == 13) cmScript.validateConfig();
else if (event.altKey || (event.target.nodeName.toLowerCase() != 'input' && key >= 33 && key <= 40)) event.preventDefault();
},
disableTabUp : function (elt)
{
elt.addEventListener('keydown', function(event)
{
var key = event.which;
if (key == 9 && event.shiftKey) event.preventDefault();
}
, false);
},
disableTabDown : function (elt)
{
elt.addEventListener('keydown', function(event)
{
var key = event.which;
if (key == 9 && !event.shiftKey) event.preventDefault();
}
, false);
},
disableScroll : function ()
{
document.body.style.overflow = 'hidden';
window.addEventListener('keydown', cmScript.disableKeys, false);
},
enableScroll : function ()
{
document.body.style.overflow = 'visible';
window.removeEventListener('keydown', cmScript.disableKeys, false);
},
alterWindow : function (opening)
{
if (opening)
{
// On fige la fenêtre
cmScript.disableScroll();
// A chaque resize, repositionnement des divs
window.addEventListener('resize', cmScript.setDivsPosition, false);
// On cache les iframes de m%$!§
getElementByXpath('//iframe', document.body).forEach(function(iframe){ iframe.style.visibility = 'hidden'; });
}
else
{
cmScript.enableScroll();
window.removeEventListener('resize', cmScript.setDivsPosition, false);
getElementByXpath('//iframe', document.body).forEach(function(iframe){ iframe.style.visibility = 'visible'; });
}
},
buildBackground : function ()
{
if (!document.getElementById('ar_back'))
{
cmScript.backgroundDiv = document.createElement("div");
cmScript.backgroundDiv.id = 'ar_back';
cmScript.backgroundDiv.addEventListener('click', function()
{
clearInterval(cmScript.timer);
cmScript.hideConfigWindow();
}
, false);
cssManager.addCssProperties("#ar_back { display: none; position: absolute; left: 0px; top: 0px; background-color: #242424; z-index: 1001;}");
document.body.appendChild(cmScript.backgroundDiv);
}
},
buildConfigWindow : function ()
{
if (top.location != self.document.location) {
return;
}
if (!document.getElementById('ar_front'))
{
cmScript.configDiv = document.createElement("div");
cmScript.configDiv.id = 'ar_front';
cmScript.configDiv.style.width = '400px';
cssManager.addCssProperties("#ar_front { display: none; vertical-align: bottom; position: absolute; background-color: #F7F7F7; z-index: 1003; border: 1px dotted #000; padding: 8px; text-align: center; font-family: Verdana;}");
cssManager.addCssProperties("#ar_front span { font-size: 0.8em;}");
cssManager.addCssProperties("#ar_front select { border: 1px solid black; font-family: Verdana; font-size: 0.75em;}");
cssManager.addCssProperties("#ar_front img { display: block; margin-top: 10px; margin-left: auto; margin-right: auto;}");
cssManager.addCssProperties("#ar_front div { position: absolute; bottom: 8px; right: 8px;}");
cssManager.addCssProperties("#ar_front input[type=image] { margin: 2px; }");
var label = document.createElement('span');
label.innerHTML = "<b>Configuration du script Auto Rehost :</b>";
cmScript.configDiv.appendChild(label);
var iconContainer = document.createElement('p');
var iconLabel = document.createElement('span');
iconLabel.innerHTML = "Icone du bouton : ";
iconContainer.appendChild(iconLabel);
var inputIcon = document.createElement('input');
inputIcon.type = 'text';
inputIcon.id = 'ar_icon';
inputIcon.size = '50';
inputIcon.value= getCurrentImgUrl();
iconContainer.appendChild(inputIcon);
cmScript.configDiv.appendChild(iconContainer);
var rehostSiteContainer = document.createElement('p');
var rehostSiteLabel = document.createElement('span');
rehostSiteLabel.innerHTML = "Site de rehost : ";
rehostSiteContainer.appendChild(rehostSiteLabel);
var inputRehostSite = document.createElement('input');
inputRehostSite.type = 'text';
inputRehostSite.id = 'ar_rehost_site';
inputRehostSite.size = '50';
inputRehostSite.value= GM_getValue("ar_rehost_site", "http://hfr-rehost.net/");
rehostSiteContainer.appendChild(inputRehostSite);
cmScript.configDiv.appendChild(rehostSiteContainer);
var rehostListContainer = document.createElement('p');
var rehostListLabel = document.createElement('span');
rehostListLabel.innerHTML = "Noms de domaine à rehoster : ";
rehostListContainer.appendChild(rehostListLabel);
var inputRehostList = document.createElement('textarea');
inputRehostList.id = 'ar_rehost_hostnames';
inputRehostList.cols = '40';
inputRehostList.rows = '8';
inputRehostList.value= getCurrentRehostables();
rehostListContainer.appendChild(inputRehostList);
cmScript.configDiv.appendChild(rehostListContainer);
var blackListContainer = document.createElement('p');
var blackListLabel = document.createElement('span');
blackListLabel.innerHTML = "Noms de domaine à <b>NE PAS</b> rehoster : ";
blackListContainer.appendChild(blackListLabel);
var blackRehostList = document.createElement('textarea');
blackRehostList.id = 'ar_bl_hostnames';
blackRehostList.cols = '40';
blackRehostList.rows = '3';
blackRehostList.value= getCurrentBl();
blackListContainer.appendChild(blackRehostList);
cmScript.configDiv.appendChild(blackListContainer);
var buttonsContainer = document.createElement('div');
var inputOk = document.createElement('input');
inputOk.type = 'image';
inputOk.src = "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%10%00%00%00%10%08%06%00%00%00%1F%F3%FFa%00%00%00%04gAMA%00%00%AF%C87%05%8A%E9%00%00%00%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7D%8E%C2%9B%3F7ayz%01e%CE%2ChXAK%A0%0E%ED%5E3%A8*bk%0B%A9%B7%04%06%F9%40%1A%EC%2BwQ%3D!%87%DA%7D%12u%D3%E5Xz%B7%80%B6%D9%06%94%0E%1E%87%C2q%02%3Ag%0E%EC%AF%BA%91n%3D%0C%AA%92%D8%3A%C4d%2B_%B8%8F%BD%1A%B3G%83%87%CC%1DT%8E%E6A%3B%9C%03%D5%90%0CJ%07%17%0E%CE%C6%A3%A5.%18%87%8A!P%F3%D6)5!%DC%F6%90%12%9BH%3A%BE%81%88%98%DCep%B0%92%D6%80%19%FA%D1%22%9C%1B%96%A3%95%DD%82%9D%85%F5%CE%22%F0Ky%11%16%A6w%7C%CA%7B%1AH%9A2%11!i%87%04%ED~3z_X%D1%3Bo%85%C5kBZK*%04%0A%5E%88R%11%F4%AE%9F%89%3AO%8A(%03%A1%A7j%08F%A0%E5%85%05*%5E%98%AD%C8%B0%D1S%A5%84%E8%AF%BF%F1_%F3%0Bg%D0%AC%E5y%BA%D4c%00%00%00%00IEND%AEB%60%82";
inputOk.alt = 'Valider';
inputOk.addEventListener('click', cmScript.validateConfig, false);
var inputCancel = document.createElement('input');
inputCancel.type = 'image';
inputCancel.src = "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%10%00%00%00%10%08%06%00%00%00%1F%F3%FFa%00%00%00%04gAMA%00%00%AF%C87%05%8A%E9%00%00%00%19tEXtSoftware%00Adobe%20ImageReadyq%C9e%3C%00%00%02!IDAT8%CB%95%93%EBN%13Q%14%85%89%89%C9%89%CF%A0V%89%86%C8%91%80%C4%1BB%5B%06(%AD%0D%08%26%D0%FB%85%5E%A4%80%B4%A5%ED%A4M%A16%EA%0FM%7C%12%9F%0BD%C5%DE%B0%D2%99v%3A%D3%E5%AE%98J-%25%E1%C7N%CEd%CE%FA%F6%AC%B5%F7%0C%00%18%B8L%D5%D7B%D7%CE%3Ew_%103%3A*%DEW%EC%0Fr%D9%ED%8D%D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ND%AEB%60%82";
inputCancel.alt = 'Annuler';
inputCancel.addEventListener('click', cmScript.hideConfigWindow, false);
cmScript.disableTabDown(inputCancel);
buttonsContainer.appendChild(inputOk);
buttonsContainer.appendChild(inputCancel);
cmScript.configDiv.appendChild(buttonsContainer);
document.body.appendChild(cmScript.configDiv);
}
},
validateConfig : function()
{
getElementByXpath('.//*[starts-with(@id, "ar_")]', document.getElementById('ar_front')).forEach(function(input)
{
GM_setValue(input.id, input.value);
}
);
cmScript.hideConfigWindow();
},
initBackAndFront : function()
{
if (document.getElementById('ar_back'))
{
cmScript.setBackgroundPosition();
cmScript.backgroundDiv.style.opacity = 0;
cmScript.backgroundDiv.style.display = 'block';
}
if (document.getElementById('ar_front'))
{
//document.getElementById('ar_alias_url').value = sleathRehost.currentAliasUrl;
}
},
showConfigWindow : function ()
{
cmScript.alterWindow(true);
cmScript.initBackAndFront();
var opacity = 0;
cmScript.timer = setInterval(function()
{
opacity = Math.round((opacity + 0.1) * 100) / 100;
cmScript.backgroundDiv.style.opacity = opacity;
if (opacity >= 0.8)
{
clearInterval(cmScript.timer);
cmScript.configDiv.style.display = 'block';
cmScript.setConfigWindowPosition();
}
}
, 1);
},
hideConfigWindow : function ()
{
cmScript.configDiv.style.display = 'none';
var opacity = cmScript.backgroundDiv.style.opacity;
cmScript.timer = setInterval(function()
{
opacity = Math.round((opacity - 0.1) * 100) / 100;
cmScript.backgroundDiv.style.opacity = opacity;
if (opacity <= 0)
{
clearInterval(cmScript.timer);
cmScript.backgroundDiv.style.display = 'none';
cmScript.alterWindow(false);
}
}
, 1);
},
setUp : function()
{
// On construit l'arrière plan
cmScript.buildBackground();
// On construit la fenêtre de config
cmScript.buildConfigWindow();
// On ajoute la css
cssManager.insertStyle();
},
createConfigMenu : function ()
{
GM_registerMenuCommand("[HFR] Auto Rehost -> Configuration", this.showConfigWindow);
}
};
cmScript.setUp();
cmScript.createConfigMenu();
// **********************************************
// Traitement de la page
// **********************************************
processNode(document);
// **********************************************
// Spécifique MesDiscussions.net
// **********************************************
var root = document.getElementById('mesdiscussions');
getElementByXpath('//table//tr[contains(@class, "message")]//div[contains(@class, "toolbar")]', root).filter(function(toolbar)
{
var newImg = document.createElement('img');
newImg.src = getCurrentImgUrl();
newImg.alt = newImg.title = 'Rehoster les images';
newImg.style.cursor = 'pointer';
newImg.style.marginRight = '3px';
newImg.addEventListener('click', function(event)
{
var knownHosts = getCurrentRehostables().split("\n");
var blHosts = getCurrentBl().split("\n");
var imgs = toolbar.nextSibling.getElementsByTagName('img') ;
var hostnames = [];
for (var i = 0; i < imgs.length; i++) {
var host = getHostname(imgs[i].src)
var isKnown = false;
for (var j = 0; j < blHosts.length && !isKnown; j++) {
if (blHosts[j] == host) {
isKnown = true;
}
}
for (var j = 0; j < knownHosts.length && !isKnown; j++) {
if (knownHosts[j] == host) {
isKnown = true;
}
}
if (!isKnown) {
hostnames[hostnames.length] = host;
knownHosts[knownHosts.length] = host;
}
}
if (hostnames.length > 0) {
if (confirm("Voulez-vous rehoster les serveurs suivants :\n" + hostnames.join("\n"))) {
GM_setValue("ar_rehost_hostnames", knownHosts.join("\n"));
processNode(toolbar.nextSibling);
}
}
else {
alert("Rien de neuf à rehoster");
}
}
, false);
var newDiv = document.createElement('div');
newDiv.className = 'right';
newDiv.appendChild(newImg);
toolbar.insertBefore(newDiv, toolbar.lastChild);
}
);
// ============ Module d'auto update du script ============
({
check4Update : function()
{
var autoUpdate = this;
var mirrorUrl = GM_getValue('mirrorUrl', 'null');
if (mirrorUrl == 'null') autoUpdate.retrieveMirrorUrl();
var currentVersion = GM_getValue('currentVersion', '4.0.6');
// On met éventuellement la version stockée à jour avec la version courante, si la version courante est plus récente
if (autoUpdate.isLater('4.0.6', currentVersion))
{
GM_setValue('currentVersion', '4.0.6');
currentVersion = '4.0.6';
}
// Par contre, si la version stockée est plus récente que la version courante -> création un menu d'update pour la dernière version
else if (autoUpdate.isLater(currentVersion, '4.0.6'))
{
GM_registerMenuCommand("[HFR] Smart Auto Rehost -> Installer la version " + currentVersion, function()
{
GM_openInTab(mirrorUrl + 'others/hfr_smart_auto_rehost.user.js');
}
);
}
// Si la version courante et la version stockée sont identiques, on ne fait rien
if (GM_getValue('lastVersionCheck') == undefined || GM_getValue('lastVersionCheck') == '') GM_setValue('lastVersionCheck', new Date().getTime() + '');
// Pas eu de check depuis 24h, on vérifie...
if ((new Date().getTime() - GM_getValue('lastVersionCheck')) > 86400000 && mirrorUrl != 'null')
{
var checkUrl = mirrorUrl + 'getLastVersion.php5?name=' + encodeURIComponent('[HFR] Smart Auto Rehost');
if (isNaN(currentVersion.substring(currentVersion.length - 1))) checkUrl += '&sversion=' + currentVersion.substring(currentVersion.length - 1);
GM_xmlhttpRequest({
method: "GET",
url: checkUrl,
onload: function(response)
{
var regExpVersion = new RegExp('^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}[a-zA-Z]?$');
var lastVersion = response.responseText;
// Pas d'erreur et nouvelle version plus récente
if (lastVersion != '-1' && regExpVersion.test(lastVersion) && autoUpdate.isLater(lastVersion, currentVersion))
{
if (confirm('Une nouvelle version de [HFR] Smart Auto Rehost est disponible : ' + lastVersion + '\nVoulez-vous l\'installer ?'))
{
GM_openInTab(mirrorUrl + 'others/hfr_smart_auto_rehost.user.js');
}
else
{
// Mémorisation de la version refusée : elle servira de version de référence
GM_setValue('currentVersion', lastVersion);
}
}
GM_setValue('lastVersionCheck', new Date().getTime() + '');
}
});
}
},
max : function(v1, v2)
{
var tabV1 = v1.split('.');
var tabV2 = v2.split('.');
if (isNaN(tabV1[2].substring(tabV1[2].length - 1))) tabV1[2] = tabV1[2].substring(0, tabV1[2].length - 1);
if (isNaN(tabV2[2].substring(tabV2[2].length - 1))) tabV2[2] = tabV2[2].substring(0, tabV2[2].length - 1);
if ((tabV1[0] > tabV2[0])
|| (tabV1[0] == tabV2[0] && tabV1[1] > tabV2[1])
|| (tabV1[0] == tabV2[0] && tabV1[1] == tabV2[1] && tabV1[2] > tabV2[2]))
{
return v1;
}
else
{
return v2;
}
},
isLater : function(v1, v2)
{
return v1 != v2 && this.max(v1, v2) == v1;
},
retrieveMirrorUrl : function()
{
var mirrors = 'http://hfr.toyonos.info/gm/;http://hfr-mirror.toyonos.info/gm/'.split(';');
var checkMirror = function (i)
{
var mirror = mirrors[i];
GM_xmlhttpRequest({
url: mirror + 'getLastVersion.php5',
method: "HEAD",
onload: function(response)
{
// Dès qu'un miroir répond, on le mémorise.
if (response.status == 200)
{
GM_setValue('mirrorUrl', mirror);
}
else
{
// Sinon on test le prochain
if ((i + 1) < mirrors.length)
{
checkMirror(i + 1);
}
else
{
GM_setValue('mirrorUrl', 'null');
}
}
}
});
};
checkMirror(0);
},
}).check4Update();