forked from reek/anti-adblock-killer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanti-adblock-killer.user.js
3157 lines (2946 loc) · 107 KB
/
anti-adblock-killer.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
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name Anti-Adblock Killer | Reek
// @namespace https://userscripts.org/scripts/show/155840
// @description Anti-Adblock Killer is a userscript whose functionality is removes many protections used on some website that force the user to disable the AdBlocker.
// @author Reek | reeksite.com
// @version 7.7
// @license Creative Commons BY-NC-SA
// @encoding utf-8
// @homepage https://github.com/reek/anti-adblock-killer#anti-adblock-killer--reek
// @twitter https://twitter.com/antiadbkiller
// @updateURL https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer.user.js
// @downloadURL https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer.user.js
// @supportURL https://github.com/reek/anti-adblock-killer/issues
// @contributionURL https://github.com/reek/anti-adblock-killer#donate
// @icon https://raw.github.com/reek/anti-adblock-killer/master/anti-adblock-killer-icon.png
// @include http*://*
// @exclude http*://*.google.*
// @exclude http*://*.yahoo.*/*
// @exclude http*://*.youtube.com/*
// @exclude http*://*.facebook.com/*
// @exclude http*://*.chromeactions.com/*
// @exclude http*://*.imgbox.com/*
// @exclude http*://*.imgur.com/*
// @exclude http*://*.reddit.com/*
// @exclude http*://*.baidu.com/*
// @exclude http*://*.wikipedia.org/*
// @exclude http*://*.linkedin.com/*
// @exclude http*://*.amazon.*/*
// @exclude http*://*.bing.com/*
// @exclude http*://*.ebay.com/*
// @exclude http*://*.pinterest.com/*
// @exclude http*://*.ask.com/*
// @exclude http*://*.live.com/*
// @exclude http*://*.msn.com/*
// @exclude http*://*.tumblr.com/*
// @exclude http*://*.microsoft.com/*
// @exclude http*://*.paypal.com/*
// @exclude http*://*.imdb.com/*
// @exclude http*://*.apple.com/*
// @exclude http*://*.ghacks.net/*
// @exclude http*://*.yandex.ru/*
// @exclude http*://*.qq.com/*
// @exclude http*://*.flickr.com/*
// @exclude http*://*.chatango.com/*
// @exclude http*://chatango.com/*
// @exclude http*://vimeo.com/*
// @exclude http*://360.cn/*
// @exclude http*://mail.ru/*
// @exclude http*://jsbin.com/*
// @exclude http*://jsfiddle.net/*
// @exclude http*://flattr.com/*
// @exclude http*://instagram.com/*
// @exclude http*://stackoverflow.com/*
// @exclude http*://youtu.be/*
// @exclude http*://twitter.com/*
// @exclude http*://t.co/*
// @exclude http*://reeksite.com/*
// @exclude http*://preloaders.net/*
// @exclude http*://tampermonkey.net/*
// @grant unsafeWindow
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_xmlhttpRequest
// @grant GM_registerMenuCommand
// @grant GM_deleteValue
// @grant GM_listValues
// @grant GM_getResourceText
// @grant GM_getResourceURL
// @grant GM_log
// @grant GM_openInTab
// @grant GM_setClipboard
// @grant GM_info
// @grant GM_getMetadata
// @run-at document-start
// ==/UserScript==
/*=====================================================
Thanks
=======================================================
Donors:
Mike Howard, Shunjou, Charmine, Kierek93, George Barnard, Henry Young, Seinhor9, ImGlodar, Ivanosevitch, HomeDipo, Roy Martin, DrFiZ, Tippy, Brian Rohner, Piotr Kozica, Minesh Patel, W4rell, Tscheckoff, AdBlock Polska, AVENIR INTERNET, coolNAO, Ben
Collaborators:
InfinityCoding, Couchy, Dindog, Floxflob, U Bless, Watilin, @prdonahue, Hoshie, 3lf3nLi3d, Alexo, Crits, Noname120, Crt32, JixunMoe, Athorcis, Killerbadger
Users:
Thank you to all those who use Anti Adblock Killer, who report problems, who write the review, which add to their favorites, making donations, which support the project and help in its development or promote.
/*=====================================================
Mirrors
=======================================================
Github:
https://github.com/reek/anti-adblock-killer
Userscripts:
https://userscripts.org/scripts/show/155840
Greasyfork:
https://greasyfork.org/scripts/735
Openuserjs:
https://openuserjs.org/scripts/reek/httpsuserscripts.orgscriptsshow155840/Anti-Adblock_Killer_Reek
MonkeyGuts:
https://monkeyguts.com/code.php?id=351
=======================================================
Documentation
=======================================================
Greasemonkey:
http://wiki.greasespot.net/Greasemonkey_Manual:API
Scriptish:
https://github.com/scriptish/scriptish/wiki/Manual%3A-API
Tampermonkey:
http://tampermonkey.net/documentation.php
Violentmonkey:
https://github.com/gera2ld/Violentmonkey-oex/wiki
NinjaKit:
https://github.com/os0x/NinjaKit
=======================================================
Script
======================================================*/
Aak = {
name : 'Anti-Adblock Killer',
version : '7.7',
scriptid : 'gJWEp0vB',
homeURL : 'https://github.com/reek/anti-adblock-killer#anti-adblock-killer--reek',
changelogURL : 'https://github.com/reek/anti-adblock-killer#changelog',
donateURL : 'https://github.com/reek/anti-adblock-killer#donate',
featuresURL : 'https://github.com/reek/anti-adblock-killer#features',
reportURL : 'https://github.com/reek/anti-adblock-killer/wiki/Report-Guide',
twitterURL : 'https://twitter.com/antiadbkiller',
downloadURL : 'https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer.user.js',
filtersSubscribe : 'abp:subscribe?location=https://raw.github.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt&title=Anti-Adblock%20Killer%20|%20Filters%20for%20Adblockers',
filtersURL : "https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt",
iconURL : 'https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-icon.png',
uw: unsafeWindow || window || false,
init : function () {
// Stop if user not use Script Manager or not support GM Api
if (Aak.ApiRequires()) {
// Debug
Aak.debug();
// Check GM Api supported
//Aak.ApiSupported();
// Add Command in Greasemonkey Menu
Aak.registerMenuCommand();
// Detect Filters
Aak.once(30, 'aak-detectfilters', Aak.detectFilters);
// Check Update
Aak.once(5, 'aak-checkupdate', Aak.update.checkAuto);
// Detect and Kill
Aak.kill();
}
},
debug : function () {
//if (Aak.isTopWindow) {
//Aak.player.dom();
//Aak.listValues();
//localStorage.clear();
//Aak.log(localStorage);
//Aak.ApiSupported();
//GM_deleteValue('aak-detectfilters');
//GM_deleteValue('aak-checkupdate');
//console.info('Anti-Adblock Killer v' + Aak.getVersion() + ' on ' + Aak.getScriptManager() + ' in ' + Aak.getBrowser(), Aak.getUUID());
//}
},
isTopWindow : !(window.top != window.self),
ready : function (fn) {
window.addEventListener('load', fn);
},
contains : function (string, search) {
return string.indexOf(search) != -1;
},
ApiRequires : function () {
if (typeof GM_xmlhttpRequest != 'undefined' &&
typeof GM_setValue != 'undefined' &&
typeof GM_getValue != 'undefined' &&
typeof GM_addStyle != 'undefined' &&
typeof GM_registerMenuCommand != 'undefined') {
return true;
} else {
return false;
}
},
ApiSupported : function () {
if (Aak.isTopWindow) {
console.info('Requires');
console.info('GM_xmlhttpRequest', (typeof GM_xmlhttpRequest != 'undefined') ? true : false);
console.info('GM_setValue', (typeof GM_setValue != 'undefined') ? true : false);
console.info('GM_getValue', (typeof GM_getValue != 'undefined') ? true : false);
console.info('GM_addStyle', (typeof GM_addStyle != 'undefined') ? true : false);
console.info('GM_registerMenuCommand', (typeof GM_registerMenuCommand != 'undefined') ? true : false);
console.info('No requires');
console.info('GM_info', (typeof GM_info != 'undefined') ? GM_info : false);
console.info('GM_getMetadata', (typeof GM_getMetadata != 'undefined') ? GM_getMetadata : false);
console.info('GM_deleteValue', (typeof GM_deleteValue != 'undefined') ? true : false);
console.info('GM_listValues', (typeof GM_listValues != 'undefined') ? true : false);
console.info('GM_getResourceText', (typeof GM_getResourceText != 'undefined') ? true : false);
console.info('GM_getResourceURL', (typeof GM_getResourceURL != 'undefined') ? true : false);
console.info('GM_log', (typeof GM_log != 'undefined') ? true : false);
console.info('GM_openInTab', (typeof GM_openInTab != 'undefined') ? true : false);
console.info('GM_setClipboard', (typeof GM_setClipboard != 'undefined') ? true : false);
}
},
listValues : function (del) {
if (typeof GM_listValues != 'undefined') {
var del = (del) ? true : false;
var list = GM_listValues();
for (var i in list) {
if (del) {
GM_deleteValue(list[i]);
} else {
Aak.log(list[i], GM_getValue(list[i]));
}
}
}
},
getBrowser : function () {
var ua = navigator.userAgent;
if (Aak.contains(ua, 'Firefox')) {
return "Firefox";
} else if (Aak.contains(ua, 'MSIE')) {
return "IE";
} else if (Aak.contains(ua, 'Opera')) {
return "Opera";
} else if (Aak.contains(ua, 'Chrome')) {
return "Chrome";
} else if (Aak.contains(ua, 'Safari')) {
return "Safari";
} else if (Aak.contains(ua, 'Konqueror')) {
return "Konqueror";
} else if (Aak.contains(ua, 'PaleMoon')) {
return "PaleMoon"; // fork firefox
} else if (Aak.contains(ua, 'Cyberfox')) {
return "Cyberfox"; // fork firefox
} else if (Aak.contains(ua, 'SeaMonkey')) {
return "SeaMonkey"; // fork firefox
} else if (Aak.contains(ua, 'Iceweasel')) {
return "Iceweasel"; // fork firefox
} else {
return ua;
}
},
getVersion : function () {
return Number(Aak.version);
},
getScriptManager : function () {
if (Aak.ApiRequires()) {
if (typeof GM_info == 'object') {
// Greasemonkey (Firefox)
if (typeof GM_info.uuid != 'undefined') {
return 'Greasemonkey';
} // Tampermonkey (Chrome/Opera)
else if (typeof GM_info.scriptHandler != 'undefined') {
return 'Tampermonkey';
}
} else {
// Scriptish (Firefox)
if (typeof GM_getMetadata == 'function') {
return 'Scriptish';
} // NinjaKit (Safari/Chrome)
else if (typeof GM_getResourceText == 'undefined' &&
typeof GM_getResourceURL == 'undefined' &&
typeof GM_openInTab == 'undefined' &&
typeof GM_setClipboard == 'undefined') {
return 'NinjaKit';
} // GreaseGoogle (Chrome)
else if (Aak.getBrowser() == 'Chrome' &&
typeof GM_setClipboard == 'undefined') {
return 'GreaseGoogle';
}
}
} else {
Aak.log('No scriptmanager detected');
return false;
}
},
generateUUID : function () {
// Universally Unique IDentifier
var d = new Date().getTime();
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c == 'x' ? r : (r & 0x7 | 0x8)).toString(16);
});
return uuid;
},
getUUID : function () {
// Universally Unique IDentifier
var store = 'aak-uuid';
if (typeof GM_getValue(store) == 'undefined') {
GM_setValue(store, Aak.generateUUID());
}
return GM_getValue(store);
},
log : function (text) {
if (typeof console.log === 'undefined') {
unsafeWindow.console.log(text);
} else {
console.log(text);
}
},
once : function (day, name, callback) {
setTimeout(function () {
if (typeof GM_getValue != 'undefined') {
// Current time
var time = new Date().getTime();
// Create setValue
if (isNaN(GM_getValue(name))) {
GM_setValue(name, 1);
}
// Execute
if (Number(GM_getValue(name)) < time) {
GM_setValue(name, (time + (day * 24 * 60 * 60 * 1000)).toString());
callback();
}
}
}, 0);
},
registerMenuCommand : function () {
Aak.ready(function () {
// Scriptish
// Note: No menu command is created when the user script is run in a iframe window.
// https://github.com/scriptish/scriptish/wiki/GM_registerMenuCommand
if (Aak.isTopWindow && typeof GM_registerMenuCommand != 'undefined') {
GM_registerMenuCommand(Aak.name + ' ' + Aak.getVersion() + ' Homepage', function () {
location.href = Aak.homeURL;
});
GM_registerMenuCommand(Aak.name + ' ' + Aak.getVersion() + ' Check Update', Aak.update.check);
}
});
},
notification : function (message, delay) {
if (Aak.isTopWindow) {
// animation
Aak.addStyle('@-webkit-keyframes aak-fadeInDown{0%{opacity:0;-webkit-transform:translateY(-20px)}100%{opacity:1;-webkit-transform:translateY(0)}}@keyframes aak-fadeInDown{0%{opacity:0;transform:translateY(-20px)}100%{opacity:1;transform:translateY(0)}}');
// box
Aak.addStyle('#aak-notice { -webkit-animation: aak-fadeInDown .5s ease; animation: aak-fadeInDown .5s ease; padding: 0px; color:#000 !important; background-color: #fff !important; display:block !important; width:100% !important; position:fixed !important; z-index: 999999 !important; left: 0; top: 0; text-align: left; vertical-align:middle; margin:0 !important; font-size:14px !important; font-family:arial !important; border-bottom:5px solid #DF3A32 !important; line-height:1.2 !important; font-variant:small-caps;}');
// navbar
Aak.addStyle('#aak-notice-navbar { background-color: #DF3A32 !important; padding: 0px 20px 0px 62px !important; background-image:url("' + Aak.iconURL + '"); background-repeat:no-repeat; background-position:20px 3px; background-size:32px; }');
// link
Aak.addStyle('.aak-navbar-link { padding: 0px 5px !important; line-height:35px !important; color: #fff !important; display: inline-block; text-decoration: none; transform: skew(345deg, 0deg); background-color: #DF3A32 !important; border-bottom:3px solid #DF3A32; }');
// link:hover
Aak.addStyle('.aak-navbar-link:hover { color: #fff !important; background-color: #000 !important; border-bottom:3px solid #fff; text-decoration: none;}');
// close
Aak.addStyle('#aak-notice-close { color:#fff; float: right !important; margin:0px 5px; padding:10px 10px 8px 10px; text-decoration: none;}');
// brand
Aak.addStyle('#aak-notice .brand { padding-right:20px !important; color: #fff !important; font-size:14px !important; }');
// content
Aak.addStyle('#aak-notice-content { padding:5px 20px; min-height:72px;}');
Aak.addStyle('#aak-notice-content a { color: #DF3A32 !important; text-decoration: none; }');
Aak.addStyle('#aak-notice-content a:hover { text-decoration: underline; }');
// remove
Aak.removeElement('#aak-notice');
// create
var node = document.createElement('div');
node.id = 'aak-notice';
node.innerHTML = '<div id="aak-notice-navbar"><b class="brand">Anti-Adblock Killer</b><a class="aak-navbar-link" title="Visit Homepage." href="' + Aak.homeURL + '">Homepage</a><a class="aak-navbar-link" title="Report issue or anti-adblock." href="' + Aak.reportURL + '">Report</a><a class="aak-navbar-link" title="See changes" href="' + Aak.changelogURL + '">Changelog</a><a class="aak-navbar-link" title="Make a donation to support the project." href="' + Aak.donateURL + '">Donate</a><a class="aak-navbar-link" title="Submit a new feature." href="' + Aak.featuresURL + '">Suggest Features</a><a class="aak-navbar-link" title="Follow on twitter." href="' + Aak.twitterURL + '">Twitter</a><a title="Close" href="javascript:void(0);" id="aak-notice-close">X</a></div><div id="aak-notice-content"><u style="font-size: 18px;">Notice:<br></u>' + message + '</div>';
// append
document.documentElement.appendChild(node);
// close (manually)
document.querySelector('#aak-notice-close').onclick = function () {
Aak.removeElement('#aak-notice');
}
// close (automatically)
setTimeout(function () {
Aak.removeElement('#aak-notice');
}, delay);
}
},
detectFilters : function () {
if (Aak.isTopWindow) {
Aak.ready(function () {
var elem = document.createElement("div");
elem.id = "k2Uw7isHrMm5JXP1Vwdxc567ZKc1aZ4I";
elem.innerHTML = "<br>";
document.body.appendChild(elem);
setTimeout(function () {
if (elem.clientHeight) {
Aak.notification('It seems that you have not subscribed to the list <b>Anti-Adblock Killer - Filters for Adblockers</b>, this list is necessary for the proper functioning of Anti-Adblock Killer. <a href="' + Aak.filtersSubscribe + '" target="_blank">Subscribe</a>', 30000);
console.warn("Anti-Adblock Killer: Filters for Adblockers No detected :( " + elem.clientHeight);
} else {
console.info("Anti-Adblock Killer: Filters for Adblockers detected");
}
}, 5000);
});
}
},
buildQuery : function (obj) {
var array = [];
for (var p in obj) {
array.push(p + '=' + obj[p]);
}
return array.join('&');
},
update : {
check : function () {
if (Aak.isTopWindow) {
Aak.notification('<b>Userscript: </b><i id="aak-update-script">Checking...</i><br/><b>Filters: </b><i id="aak-update-filters">Checking...</i>', 60000);
setTimeout(function () {
Aak.update.getLatestVerScript();
Aak.update.getLatestVerFilters();
}, 2000);
}
},
checkAuto : function () {
if (Aak.isTopWindow) {
Aak.ready(function () {
var data = {
scriptid : Aak.scriptid,
uuid : Aak.getUUID(),
version : Aak.getVersion(),
browser : Aak.getBrowser(),
scriptmanager : Aak.getScriptManager()
};
GM_xmlhttpRequest({
timeout : 10000, // 10s
method : "POST",
data : Aak.buildQuery(data),
url : 'http://reeksite.com/php/get.php?checkupdate',
headers : {
"Content-Type" : "application/x-www-form-urlencoded"
},
onload : function (response) {
var res = response.responseText;
var status = response.status;
var json = JSON.parse(res);
Aak.log(res, status, json);
if (status == 200 && typeof json == 'object' && json.update) {
Aak.downloadURL = json.url;
Aak.update.check();
}
}
});
});
}
},
getLatestVerScript : function () {
GM_xmlhttpRequest({
timeout : 5000, // 5s
method : "GET",
url : Aak.downloadURL,
onload : function (response) {
var res = response.responseText;
var status = response.status;
//Aak.log(status, res);
if (status == 200) {
var verInstalled = Aak.getVersion();
var verLatest = Number(res.match(/@version\s+(\d+\.\d+)/)[1]);
if (verInstalled < verLatest) {
var message = ' ' + verLatest + ' available <a title="Install latest version" href="' + Aak.downloadURL + '" target="_blank">Install</a>';
} else {
var message = 'Up-to-date ✔';
}
} else {
var message = '<i style="color:#c00;">Checking failed ✘</i>';
}
var notification = document.querySelector('#aak-update-script');
notification.innerHTML = message;
},
ontimeout : function () {}
});
},
getLatestVerFilters : function () {
GM_xmlhttpRequest({
timeout : 5000, // 5s
method : "GET",
url : Aak.filtersURL,
onload : function (response) {
var res = response.responseText;
var status = response.status;
//Aak.log(status, res);
if (status == 200) {
var verInstalled = Aak.getVersion();
var verLatest = Number(res.match(/!\s+Version:\s+(\d+\.\d+)/)[1]);
if (verInstalled < verLatest) {
var message = ' ' + verLatest + ' available <a title="Install latest version" id="aak-subscribe" href="' + Aak.filtersSubscribe + '" target="_blank">Install</a>';
} else {
var message = 'Up-to-date ✔';
}
} else {
var message = '<i style="color:#c00;">Checking failed ✘</i>';
}
var notification = document.querySelector('#aak-update-filters');
notification.innerHTML = message;
},
ontimeout : function () {}
});
}
},
autoReport : function (system, host, target) {
var host = (host) ? host : location.host;
var target = (target) ? target : '';
var name = 'Aak' + system;
Aak.log(system);
if (typeof localStorage != "undefined") {
if (typeof localStorage[name] == "undefined") {
// w3schools.com/html/html5_webstorage.asp
// Using localStorage because GM get/setValue does not work
localStorage[name] = host;
var data = {
system : system,
host : host,
target : target
};
GM_xmlhttpRequest({
timeout : 10000, // 10s
method : "POST",
data : Aak.buildQuery(data),
url : 'http://reeksite.com/php/get.php?autoreport',
headers : {
"Content-Type" : "application/x-www-form-urlencoded"
},
onload : function (response) {
var res = response.responseText;
var status = response.status;
//Aak.log(res, status);
}
});
} else {
//Aak.log('Already reported !');
}
} else {
console.warn('Sorry! No Web Storage support.');
}
},
setStorage : function () {
if (localStorage) {
// Le navigateur supporte le localStorage
} else {
//throw 'localStorage non supporté';
}
},
getStorage : function () {
if (localStorage) {
// Le navigateur supporte le localStorage
} else {
//throw 'localStorage non supporté';
}
},
getReadme : function (selector) {
GM_xmlhttpRequest({
method : "GET",
url : Aak.homeURL,
headers : {
"User-Agent" : navigator.userAgent,
"Accept" : "text/html"
},
onload : function (response) {
var res = response.responseText;
var parser = new DOMParser();
var dom = parser.parseFromString(res, "text/html");
var readme = dom.querySelector("div#readme article.markdown-body");
//Aak.log(readme);
document.querySelector(selector).appendChild(readme);
}
});
},
getChangelog : function () {
GM_xmlhttpRequest({
method : "GET",
url : Aak.changelogURL,
headers : {
"User-Agent" : navigator.userAgent,
"Accept" : "text/html"
},
onload : function (response) {
var res = response.responseText;
var parser = new DOMParser();
var dom = parser.parseFromString(res, "text/html");
var elem = dom.querySelector("#post-body-505690");
Aak.notification(elem.textContent, 60000);
}
});
},
kill : function () {
// Detect & Kill
for (var i in Aak.rules) {
// Current
current = Aak.rules[i];
// RegExp host
var reHost = new RegExp(current.host.join('|'), 'i');
// If domains is
if (reHost.test(location.host)) {
// On all statements
if (current.onAlways) {
current.onAlways();// loading
window.addEventListener('DOMContentLoaded', current.onAlways); // interactive
window.addEventListener('load', current.onAlways); // complete
}
// Add Js / Css / Cookie
if (current.onStart) {
current.onStart();
}
// When Before Script Executed
if (current.onBeforeScript) {
if ('onbeforescriptexecute' in document) { // Mozilla Firefox
window.addEventListener('beforescriptexecute', current.onBeforeScript);
}
// Opera
// Doc: http://www.opera.com/docs/userjs/specs/
} // When After Script Executed
if (current.onAfterScript) {
if ('onafterscriptexecute' in document) { // Mozilla Firefox
window.addEventListener('afterscriptexecute', current.onAfterScript);
}
}
// When Window Load
if (current.onEnd) {
window.addEventListener('load', current.onEnd);
}
// When DOM Load
if (current.onLoad) {
window.addEventListener('DOMContentLoaded', current.onLoad);
}
// When DOM AttrModified
if (current.onAttrModified) {
window.addEventListener('DOMAttrModified', current.onAttrModified, false);
}
// When DOM SubtreeModified
if (current.onSubtreeModified) {
window.addEventListener('DOMSubtreeModified', current.onSubtreeModified, false);
}
// When DOM Elements are Inserted in Document
if (current.onInsert) {
// Mutation Observer
// developer.mozilla.org/en-US/docs/Web/API/MutationObserver
// caniuse.com/mutationobserver
if (typeof window.MutationObserver != 'undefined' ||
typeof WebKitMutationObserver != 'undefined') {
// Mutation Observer
var MutationObserver = window.MutationObserver || WebKitMutationObserver;
// Create an observer instance
var obs = new MutationObserver(function (mutations) {
// We can safely use `forEach` because we already use mutation
// observers that are more recent than `forEach`. (source: MDN)
mutations.forEach(function (mutation) {
// we want only added nodes
if (mutation.addedNodes.length) {
//Aak.log(addedNodes);
Array.prototype.forEach.call(mutation.addedNodes, function (addedNode) {
//Aak.log(addedNode);
current.onInsert(addedNode);
});
}
});
});
// Observer
obs.observe(document, {
childList : true,
subtree : true
});
}
// Mutation Events (Alternative Solution)
// developer.mozilla.org/en-US/docs/Web/Guide/Events/Mutation_events
else {
window.addEventListener("DOMNodeInserted", function (e) {
current.onInsert(e.target);
}, false);
}
}
// When DOM Elements are Removed in Document
if (current.onRemove) {
// Mutation Observer
// developer.mozilla.org/en-US/docs/Web/API/MutationObserver
// caniuse.com/mutationobserver
if (typeof window.MutationObserver != 'undefined' ||
typeof WebKitMutationObserver != 'undefined') {
// Mutation Observer
var MutationObserver = window.MutationObserver || WebKitMutationObserver;
// Create an observer instance
var obs = new MutationObserver(function (mutations) {
// We can safely use `forEach` because we already use mutation
// observers that are more recent than `forEach`. (source: MDN)
mutations.forEach(function (mutation) {
// we want only removed nodes
if (mutation.removedNodes.length) {
//Aak.log(mutation.removedNodes);
Array.prototype.forEach.call(mutation.removedNodes, function (removedNode) {
//Aak.log(removedNode);
current.onRemove(removedNode);
});
}
});
});
// Observer
obs.observe(document, {
childList : true,
subtree : true
});
}
// Mutation Events (Alternative Solution)
// developer.mozilla.org/en-US/docs/Web/Guide/Events/Mutation_events
else {
window.addEventListener("DOMNodeRemoved", function (e) {
current.onRemove(e.target);
}, false);
}
}
}
}
},
confirmLeave : function () {
window.onbeforeunload = function () {
return '';
};
},
confirmReport : function (element) {
element.innerHTML = 'Report';
element.title = 'Report issue or anti-adblock';
element.onclick = function (e) {
e.preventDefault();
if (confirm("Do you want to report issue or anti-adblock")) { // Clic on OK
location.href = Aak.reportURL;
} else {
location.href = element.href;
}
}
},
stopScript : function (e) {
e.preventDefault();
e.stopPropagation();
},
innerScript : function (e) {
return e.target.innerHTML;
},
addScript : function (code) {
// Note: Scriptish no support
if (document.head) {
if (/\.js$/.test(code)) { // External
document.head.appendChild(document.createElement('script')).src = code;
} else { // Inline
document.head.appendChild(document.createElement('script')).innerHTML = code.toString().replace(/^function.*{|}$/g, '');
}
}
},
addElement : function (str) { // ex: div.ads or span#ads
if (Aak.contains(str, '.')) {
var str = str.replace('.', ':className:');
} else if (Aak.contains(str, '#')) {
var str = str.replace('#', ':id:');
}
var arr = str.split(':');
Aak.addScript('function() { document.documentElement.appendChild(document.createElement("' + arr[0] + '")).' + arr[1] + ' = "' + arr[2] + '"; document.querySelector("' + arr[0] + '").innerHTML = "<br>"; }');
},
removeElement : function (o) {
if (o instanceof HTMLElement) {
return o.parentNode.removeChild(o);
} else if (typeof o === "string") {
var elem = document.querySelectorAll(o);
for (var i = 0; i < elem.length; i++) {
elem[i].parentNode.removeChild(elem[i]);
}
} else {
return false;
}
},
getElement : function (selector) {
var elem = document.querySelector(selector) || false;
if (elem) {
return elem;
} else {
return false;
}
},
setElement : function (selector, props) {
var elem = Aak.getElement(selector);
if (elem) {
for (p in props) {
elem.setAttribute(p, props[p]);
}
} else {
return false;
}
},
addStyle : function (css) {
GM_addStyle(css);
},
getStyle : function (el, styleProp) {
if (el.currentStyle)
return el.currentStyle[styleProp];
else if (window.getComputedStyle)
return document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp);
},
getCookie : function (sName) {
var oRegex = new RegExp("(?:; )?" + sName + "=([^;]*);?");
if (oRegex.test(document.cookie)) {
return decodeURIComponent(RegExp["$1"]);
} else {
return null;
}
},
setCookie : function (sName, sValue, sTime) {
sTime = (sTime) ? sTime : 365 * 24 * 60 * 60 * 1000;
var today = new Date(),
expires = new Date();
expires.setTime(today.getTime() + sTime); // 365*24*60*60*1000
document.cookie = sName + "=" + encodeURIComponent(sValue) + ";expires=" + expires.toGMTString() + ";path=/";
},
decodeURI : function (str) {
return decodeURIComponent(str);
},
encodeURI : function (str) {
return encodeURIComponent(str);
},
encodeHTML : function (str) {
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
},
decodeHTML : function (str) {
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
},
uniqid : function () {
return 'Aak-' + Math.random().toString(36).substring(4);
},
allowfullscreen : function (elem, boolen) {
var boolen = (boolen) ? boolen : true;
if (typeof elem == 'string') {
var elem = document.querySelector(elem);
}
var parent = elem.parentNode;
var clone = elem.cloneNode(true);
var params = clone.querySelector('param[name="allowfullscreen"]') || false;
if (params) {
params.value = boolen;
}
if (typeof clone.allowfullscreen != 'undefined') {
clone.allowfullscreen = boolen;
}
// Replace
parent.replaceChild(clone, elem);
},
player : { // http://tinyurl.com/pb6fthj
in : {
node : null,
html : null,
tag : null,
parent : null
},
out : {
node : null,
html : null,
tag : null,
parent : null
},
nameplayer : 'custom',
swfvars : null,
options : {
method : 'replace',
output : 'embed'
},
flashvars : {
str : null,
obj : {}
},
attributes : {
wmode : 'opaque',
quality : 'high',
bgcolor : '#000000',
type : 'application/x-shockwave-flash',
pluginspage : 'http://www.adobe.com/go/getflash',
allowscriptaccess : 'always', // never / always
allowfullscreen : true
},
dom : function () {
GM_registerMenuCommand(Aak.name + ' ' + Aak.getVersion() + ' swfobjects', function () {
var elems = document.querySelectorAll('embed,object');
for (var i = 0; i < elems.length; i++) {
this.custom(elems[i]);
this.log();
}
});
},
get : function (element) {
if (element instanceof HTMLElement) {
this.in.node = element;
} else if (typeof element == 'string') {
if (/^[#\.]/.test(element)) {
this.in.node = document.querySelector(element);
} else {
this.in.node = document.getElementById(element);
}
} else {
throw 'Not object or embed player or invalid selector';
}
this.in.html = this.getHtml(this.in.node);
this.in.parent = this.in.node.parentNode;
this.in.tag = this.in.node.tagName;
this.attributes.id = this.attributes.name = Aak.uniqid();
this.attributes.height = this.in.node.height || this.in.node.clientHeight || '100%';
this.attributes.width = this.in.node.width || this.in.node.clientWidth || '100%';
if (/^(object|embed)$/i.test(this.in.tag)) {
//
this.attributes.src = this.in.node.src || this.in.node.data || false;
this.flashvars.str = this.in.node.flashvars || this.in.node.querySelector('param[name="flashvars"]') && this.in.node.querySelector('param[name="flashvars"]').value || false;
var swfvars = !this.flashvars.str && this.in.node.data && this.in.node.data.split('?', 2) || false;
//
if (swfvars) {
this.attributes.src = swfvars[0];
this.flashvars.str = swfvars[1];
}
this.splitVars();
this.joinVars();
}
//Aak.log(this);
},
custom : function (element, attributes, flashvars, options) {
//
this.get(element);
//
if (typeof attributes == 'object') {
this.mergeObj(this.attributes, attributes);
}
//
if (typeof flashvars == 'object') {
if (flashvars.set) {
this.setVars(flashvars.set);
}
if (flashvars.remove) {
this.removeVars(flashvars.remove);
}
}
//
if (typeof options == 'object') {
if (options.method) {
this.options.method = options.method;
}
if (options.output) {
this.options.output = options.output;
}