forked from reek/anti-adblock-killer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
anti-adblock-killer.user.js
3300 lines (3174 loc) · 116 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 8.0
// @encoding utf-8
// @license https://creativecommons.org/licenses/by-nc-sa/4.0/
// @icon https://raw.github.com/reek/anti-adblock-killer/master/anti-adblock-killer-icon.png
// @homepage https://github.com/reek/anti-adblock-killer#anti-adblock-killer--reek
// @twitterURL https://twitter.com/antiadbkiller
// @supportURL https://github.com/reek/anti-adblock-killer/issues
// @contributionURL https://github.com/reek/anti-adblock-killer#donate
// @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
// @include http*://*
// @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: M. Howard, Shunjou, Charmine, Kierek93, G. Barnard, H. Young, Seinhor9, ImGlodar, Ivanosevitch, HomeDipo, R. Martin, DrFiZ, Tippy, B. Rohner, P. Kozica, M. Patel, W4rell, Tscheckoff, AdBlock Polska, AVENIR INTERNET, coolNAO, Ben, J. Park, C. Young, J. Bou, M. Cano
Collaborators: InfinityCoding, Couchy, Dindog, Floxflob, U Bless, Watilin, @prdonahue, Hoshie, 3lf3nLi3d, Alexo, Crits, Noname120, Crt32, JixunMoe, Athorcis, Killerbadger, SMed79, Alexander255, Anonsubmitter, RaporLoLpro, Maynak00, Robotex, Vinctux
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: http://tinyurl.com/mcra3dn
Greasyfork: http://tinyurl.com/puyxrn4
Openuserjs: http://tinyurl.com/nnqje32
MonkeyGuts: http://tinyurl.com/ka5fcqm
Userscripts: http://tinyurl.com/q8xcejl
=======================================================
Documentation
=======================================================
Greasemonkey: http://tinyurl.com/yeefnj5
Scriptish: http://tinyurl.com/cnd9nkd
Tampermonkey: http://tinyurl.com/pdytfde
Violentmonkey: http://tinyurl.com/n34wn6j
NinjaKit: http://tinyurl.com/pkkm9ug
=======================================================
Script
======================================================*/
Aak = {
name : 'Anti-Adblock Killer',
version : '8.0',
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',
subscribeURL : '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',
listURL : "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',
excludes : ["360.cn", "amazon.", "apple.com", "ask.com", "baidu.com", "bing.com", "bufferapp.com", "chatango.com", "chromeactions.com", "easyinplay.net", "ebay.com", "facebook.com", "flattr.com", "flickr.com", "ghacks.net", "google.", "imdb.com", "imgbox.com", "imgur.com", "instagram.com", "jsbin.com", "jsfiddle.net", "linkedin.com", "live.com", "mail.ru", "microsoft.com", "msn.com", "paypal.com", "pinterest.com", "preloaders.net", "qq.com", "reddit.com", "reeksite.com", "stackoverflow.com", "tampermonkey.net", "tumblr.com", "twitter.com", "vimeo.com", "wikipedia.org", "w3schools.com", "yahoo.", "yandex.ru", "youtu.be", "youtube.com", "movie-box.pl"],
debug : {
log : true,
exclude : false,
dump : false,
inserted : false,
removed : false
},
initialize : function () {
// Debug
if (Aak.debug.dump) {
Aak.log(Aak);
Aak.log(Aak.apiSupported());
Aak.log(Aak.getScriptManager());
Aak.log(Aak.getBrowser());
}
// Script Manager
if (Aak.getScriptManager()) {
Aak.registerCommands();
Aak.update.automatic();
Aak.listDetect();
Aak.blockDetect();
} else { // Native
throw "Sorry! No Native support..";
}
},
uw : unsafeWindow || window,
$ : unsafeWindow.$ || unsafeWindow.jQuery || null,
isTopWindow : !(window.top != window.self),
ready : function (callback) {
window.addEventListener('load', callback);
},
contains : function (string, search) {
return string.indexOf(search) != -1;
},
log : function (data, method) {
if (Aak.debug.log) {
console = console || unsafeWindow.console;
console[method || 'info']('Aak' + Aak.getVersion(), data);
}
},
dumpDOM : function (delay) {
setTimeout(function () {
var array = [];
var win = Aak.uw;
for (var k in win) {
var curr = win[k];
if (typeof curr === 'object') {
try {
array.push(k + ': ' + JSON.stringify(curr));
} catch (e) {
console.log(k, typeof curr, curr);
}
}
}
document.body.innerHTML = '<textarea width="100%" height="500px">{' + array.join(',') + '}</textarea>';
}, delay || 0);
},
apiSupported : function () {
if (Aak.isTopWindow) {
// GM API - http://tinyurl.com/yeefnj5
return {
GM_xmlhttpRequest : typeof GM_xmlhttpRequest != 'undefined',
GM_setValue : typeof GM_setValue != 'undefined',
GM_getValue : typeof GM_getValue != 'undefined',
GM_addStyle : typeof GM_addStyle != 'undefined',
GM_registerMenuCommand : typeof GM_registerMenuCommand != 'undefined',
GM_info : typeof GM_info != 'undefined',
GM_getMetadata : typeof GM_getMetadata != 'undefined',
GM_deleteValue : typeof GM_deleteValue != 'undefined',
GM_listValues : typeof GM_listValues != 'undefined',
GM_getResourceText : typeof GM_getResourceText != 'undefined',
GM_getResourceURL : typeof GM_getResourceURL != 'undefined',
GM_log : typeof GM_log != 'undefined',
GM_openInTab : typeof GM_openInTab != 'undefined',
GM_setClipboard : typeof GM_setClipboard != 'undefined'
}
}
},
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 (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_setValue != 'undefined' &&
typeof GM_getResourceText == 'undefined' &&
typeof GM_getResourceURL == 'undefined' &&
typeof GM_openInTab == 'undefined' &&
typeof GM_setClipboard == 'undefined') {
return 'NinjaKit';
} else { // Native
return false;
}
}
},
generateID : function (len) {
var str = '';
var len = len || 10;
var charset = "abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (var i = 0; i < len; ++i) {
str += charset.charAt(Math.floor(Math.random() * charset.length));
}
return str;
},
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 () {
var name = 'aak-uuid';
if (Aak.getValue(name) == 'undefined') {
Aak.setValue(name, Aak.generateUUID());
}
return Aak.getValue(name);
},
once : function (day, name, callback) {
setTimeout(function () {
var later = isNaN(Aak.getValue(name)) ? 1 : Number(Aak.getValue(name));
var now = new Date().getTime();
if (later < now) {
Aak.setValue(name, (now + (day * 24 * 60 * 60 * 1000)).toString());
callback();
}
}, 1e3);
},
registerCommands : function () {
Aak.ready(function () {
// Scriptish
// note: No menu command is created when the user script is run in a iframe window.
// doc: http://tinyurl.com/kvvv7yt
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() + ' Update', Aak.update.manual);
}
});
},
notification : function (message, delay) {
if (Aak.isTopWindow) {
// css
// tool: http://csscompressor.com/
// animate: http://daneden.github.io/animate.css/
// crimson: #DC143C
Aak.addStyle('#aak-notice{font-family:arial;color:#000;font-variant:small-caps;font-size:14px;border:1px solid #999;border-radius:3px;box-shadow:1px 1px 12px #555;width:400px;max-width:400px;min-height:100px;top:0;left:0;line-height:1.2;z-index:999999;position:fixed;display:block;background-color:#fff;background-image:url(https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-icon.png);background-repeat:no-repeat;background-position:10px center;background-size:80px;margin:10px}#aak-notice-content{background-color:#fff;width:260px;min-height:70px;margin:20px 10px 10px 100px;text-align:left}.aak-notice-ok{float:right;bottom:10px;right:10px;position:absolute;font-size:12px;border:2px solid #DC143C;background-color:#DC143C;color:#FFF;padding:5px 10px;text-decoration:none;-webkit-transition:all .3s;transition:all .3s}.aak-notice-ok:hover{background-color:#FFF;color:#DC143C;text-decoration:none}#aak-notice-close{float:right;top:10px;right:10px;cursor:pointer;width:16px;height:16px;position:absolute}@-webkit-keyframes bounceInLeft{0%,60%,75%,90%,100%{-webkit-transition-timing-function:cubic-bezier(0.215,0.610,0.355,1.000);transition-timing-function:cubic-bezier(0.215,0.610,0.355,1.000)}0%{opacity:0;-webkit-transform:translate3d(-3000px,0,0);transform:translate3d(-3000px,0,0)}60%{opacity:1;-webkit-transform:translate3d(25px,0,0);transform:translate3d(25px,0,0)}75%{-webkit-transform:translate3d(-10px,0,0);transform:translate3d(-10px,0,0)}90%{-webkit-transform:translate3d(5px,0,0);transform:translate3d(5px,0,0)}100%{-webkit-transform:none;transform:none}}@keyframes bounceInLeft{0%,60%,75%,90%,100%{-webkit-transition-timing-function:cubic-bezier(0.215,0.610,0.355,1.000);transition-timing-function:cubic-bezier(0.215,0.610,0.355,1.000)}0%{opacity:0;-webkit-transform:translate3d(-3000px,0,0);transform:translate3d(-3000px,0,0)}60%{opacity:1;-webkit-transform:translate3d(25px,0,0);transform:translate3d(25px,0,0)}75%{-webkit-transform:translate3d(-10px,0,0);transform:translate3d(-10px,0,0)}90%{-webkit-transform:translate3d(5px,0,0);transform:translate3d(5px,0,0)}100%{-webkit-transform:none;transform:none}}.bounceInLeft{animation-name:bounceInLeft;animation-duration:1s;-webkit-animation-name:bounceInLeft;-webkit-animation-duration:1s}@-webkit-keyframes bounceOutLeft{20%{opacity:1;-webkit-transform:translate3d(20px,0,0);transform:translate3d(20px,0,0)}100%{opacity:0;-webkit-transform:translate3d(-2000px,0,0);transform:translate3d(-2000px,0,0)}}@keyframes bounceOutLeft{20%{opacity:1;-webkit-transform:translate3d(20px,0,0);transform:translate3d(20px,0,0)}100%{opacity:0;-webkit-transform:translate3d(-2000px,0,0);transform:translate3d(-2000px,0,0)}}.bounceOutLeft{animation-name:bounceOutLeft;animation-duration:1s;-webkit-animation-name:bounceOutLeft;-webkit-animation-duration:1s}@-webkit-keyframes fadeIn{0%{opacity:0}100%{opacity:1}}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}.fadeIn{-webkit-animation-name:fadeIn;-webkit-animation-duration:3s;animation-name:fadeIn;animation-duration:3s}');
// remove
Aak.removeElement('#aak-notice');
setTimeout(function () {
Aak.createElement({
tag : 'div',
id : 'aak-notice',
class : 'bounceInLeft',
html : '<img id="aak-notice-close" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAIVBMVEXcFDwAAADcFDzcFDzcFDzcFDzcFDzcFDzcFDzcFDzcFDxaSbB2AAAACnRSTlP9AASnuEmihYQNEux+bAAAAHpJREFUCNc9jjEKwkAURB8YQX4326jlsri1bJkqtZVYWu4NbK30CN7gQxTBU5olkKkGhuE9dHjFsL8IPYqUNmLnYwy9PTlDSbAmQzdAJRwBVhElgCKkk/lbrQzQSSxT6H9Txkj2drfK1awk9w/bGXFD9yrlr5qGNGn8AcsRF4P77o1SAAAAAElFTkSuQmCC"/><div id="aak-notice-content">' + message + '</div>',
to : 'body'
});
var close = function () {
Aak.getElement('#aak-notice').className = 'bounceOutLeft';
setTimeout(function () {
Aak.removeElement('#aak-notice');
}, 1e3);
};
// close (manually)
Aak.getElement('#aak-notice-close').onclick = function () {
close();
};
// close (automatically)
setTimeout(function () {
close();
}, delay);
}, 50);
}
},
listDetect : function () {
if (Aak.isTopWindow) {
Aak.ready(function () {
Aak.once(30, 'aak-checklist', function () {
var elem = document.createElement("div");
elem.id = "k2Uw7isHrMm5JXP1Vwdxc567ZKc1aZ4I";
elem.innerHTML = "<br>";
document.body.appendChild(elem);
setTimeout(function () {
if (elem.clientHeight) {
Aak.notification('<p>It seems that you have not subscribed to <b>AakList (Anti-Adblock Killer )</b>. <a class="aak-notice-ok" href="' + Aak.subscribeURL + '" target="_blank">Subscribe</a></p>', 3e4);
Aak.log("AakList not detected !" + elem.clientHeight, 'warn');
} else {
Aak.log("AakList detected !");
}
}, 5e3);
});
});
}
},
openInTab : function (url) {
if (typeof GM_openInTab != 'undefined') {
GM_openInTab(url);
} else {
var newWindow = window.open(url, "_blank");
newWindow.focus();
}
},
request : function (settings) {
// doc: http://tinyurl.com/2t7wbr
settings.url = settings.url || '';
settings.method = settings.method || 'GET';
settings.headers = settings.headers || {};
settings.timeout = settings.timeout || 2e4; // 20s
if (typeof GM_xmlhttpRequest != 'undefined') {
if (settings.data || settings.method == 'POST') {
settings.method = 'POST';
settings.data = Aak.serialize(settings.data || {});
settings.headers = Aak.setProperty(settings.headers, {
'X-Requested-With' : 'XMLHttpRequest',
'Content-Type' : 'application/x-www-form-urlencoded'
});
}
GM_xmlhttpRequest(settings);
} else {
throw "Sorry! No GM XMLHttpRequest support..";
}
},
update : {
manual : function () {
if (Aak.isTopWindow) {
Aak.notification('<p>Checking...</p>', 6e4);
Aak.update.getRemote();
}
},
automatic : function () {
if (Aak.isTopWindow) {
Aak.ready(function () {
Aak.once(5, 'aak-checkupdate', function () {
Aak.request({
url : 'http://reeksite.com/php/get.php?checkupdate',
data : {
scriptid : Aak.scriptid,
uuid : Aak.getUUID(),
version : Aak.getVersion(),
browser : Aak.getBrowser(),
scriptmanager : Aak.getScriptManager()
},
onload : function (response) {
try {
var res = response.responseText;
var json = JSON && JSON.parse(res);
if (json.update) {
Aak.downloadURL = json.url;
Aak.update.manual();
}
} catch (e) {
Aak.log(response, 'error');
}
}
});
});
});
}
},
getRemote : function () {
Aak.request({
url : Aak.downloadURL,
onload : function (response) {
var html = '<p>Failed...</p>';
var res = response.responseText;
var status = response.status;
if (status == 200) {
var local = Aak.getVersion();
var remote = Number(res.match(/@version\s+(\d+\.\d+)/)[1]);
if (local < remote) {
var html = '<p>Anti-Adblock Killer v' + remote + ' is available.</p><p class="aak-notice-center"><a class="aak-notice-ok" target="_blank" href="' + Aak.downloadURL + '">Install</a></p>';
} else {
var html = '<p>Anti-Adblock Killer is up to date.</p>';
}
}
Aak.getElement('#aak-notice-content').innerHTML = html;
}
});
}
},
autoReport : function (system, host, target) {
var host = host || location.host;
var target = target || '';
if (Aak.getLocal(system) == "undefined") {
Aak.setLocal(system, host); // save
Aak.request({
url : 'http://reeksite.com/php/get.php?autoreport',
data : {
system : system,
host : host,
target : target
},
onload : function (response) {
var res = response.responseText;
//Aak.log(res);
}
});
}
Aak.log(system);
},
setValue : function (name, value) {
if (typeof GM_setValue !== "undefined") {
GM_setValue(name, value);
} else {
throw "Sorry! No GM Storage support..";
}
},
getValue : function (name) {
if (typeof GM_getValue !== "undefined") {
return GM_getValue(name) || 'undefined';
} else {
throw "Sorry! No GM Storage support..";
}
},
setLocal : function (name, value) {
// doc: http://tinyurl.com/8peqwvd
if (typeof localStorage !== "undefined") {
localStorage[name] = value;
} else {
throw "Sorry! No Web Storage support..";
}
},
getLocal : function (name) {
if (typeof localStorage !== "undefined") {
return localStorage[name] || 'undefined';
} else {
throw "Sorry! No Web Storage support..";
}
},
setSession : function (name, value) {
// Doc: http://tinyurl.com/8peqwvd
if (typeof sessionStorage !== "undefined") {
sessionStorage[name] = value;
} else {
throw "Sorry! No Web Storage support..";
}
},
getSession : function (name) {
if (typeof sessionStorage !== "undefined") {
return sessionStorage[name] || 'undefined';
} else {
throw "Sorry! No Web Storage support..";
}
},
setCookie : function (name, value, time) {
var time = (time) ? time : 365 * 24 * 60 * 60 * 1000; // 1 year
var expires = new Date();
expires.setTime(new Date().getTime() + time);
document.cookie = name + "=" + encodeURIComponent(value) + ";expires=" + expires.toGMTString() + ";path=/";
},
getCookie : function (name) {
var oRegex = new RegExp("(?:; )?" + name + "=([^;]*);?");
if (oRegex.test(document.cookie)) {
return decodeURIComponent(RegExp["$1"]);
}
},
stopRedirect : function () {
if ('watch' in window) {
Aak.uw.watch("location", function () {});
Aak.uw.location.watch("href", function () {});
} else {
Aak.uw.location = "#";
throw 'Stop Redirect';
}
},
confirmLeave : function () {
window.onbeforeunload = function () {
return '';
};
},
confirmReport : function (elem) {
elem.innerHTML = 'Report';
elem.title = 'Report issue or anti-adblock';
elem.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 = elem.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, '');
}
}
},
onElement : function (element, callback, repeat) {
var repeat = repeat || 10;
var loop = setInterval(function () {
var elem = Aak.getElement(element);
if (elem) {
callback();
clearInterval(loop);
}
repeat = (repeat) ? repeat - 1 : clearInterval(loop);
}, 1e3);
},
addElement : function (str) { // ex: div.ads or span#ads
var split = str.replace('.', ':className:').replace('#', ':id:').split(':');
Aak.addScript('function() { document.documentElement.appendChild(document.createElement("' + split[0] + '")).' + split[1] + ' = "' + split[2] + '"; document.querySelector("' + str + '").innerHTML = "<br>"; }');
},
removeElement : function (elem) {
if (elem instanceof HTMLElement) {
return elem.parentNode.removeChild(elem);
} else if (typeof elem === "string") {
var elem = document.querySelectorAll(elem);
for (var i = 0; i < elem.length; i++) {
elem[i].parentNode.removeChild(elem[i]);
}
} else {
Aak.log('Error ' + elem + ' not removed !');
}
},
getElement : function (elem) {
if (typeof elem == 'string') {
return document.querySelector(elem) || false;
} else if (elem instanceof HTMLElement) {
return elem;
} else {
return false;
//throw 'Not object or invalid selector';
}
},
createElement : function (props) {
var node = {};
for (var name in props) {
switch (name) {
case "tag":
var node = document.createElement(props[name]);
break;
case "text":
var text = ('innerText' in document) ? 'innerText' : 'textContent';
node[text] = props[name];
break;
case "html":
node.innerHTML = props[name];
break;
case "class":
node.className = props[name];
break;
case "to":
var elem = Aak.getElement(props[name]);
elem.appendChild(node);
break;
case "before":
var elem = Aak.getElement(props[name]);
elem.parentNode.insertBefore(node, elem);
break;
case "after":
var elem = Aak.getElement(props[name]);
elem.parentNode.insertBefore(node, elem.nextSibling);
break;
case "replace":
var elem = Aak.getElement(props[name]);
elem.parentNode.replaceChild(node, elem);
break;
default:
node[name] = props[name];
}
}
},
replaceElement : function (oldNode, newNode) {
oldNode.parentNode.replaceChild(newNode, oldNode);
},
setElement : function (selector, props) {
var node = Aak.getElement(selector);
if (node) {
for (var name in props) {
switch (name) {
case "text":
var text = ('innerText' in document) ? 'innerText' : 'textContent';
node[text] = props[name];
break;
case "html":
node.innerHTML = props[name];
break;
case "class":
node.className = props[name];
break;
default:
node[name] = props[name];
}
}
}
},
addStyle : function (css) {
var css = css.replace(/;/g, ' !important;');
if (typeof GM_addStyle != 'undefined') {
GM_addStyle(css);
} else {
document.head.appendChild(document.createElement('style')).innerHTML = css;
}
},
getStyle : function (selector, prop) {
var elem = Aak.getElement(selector);
if (elem.currentStyle) {
return elem.currentStyle[prop];
} else if (window.getComputedStyle) {
return document.defaultView.getComputedStyle(elem, null).getPropertyValue(prop);
}
},
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, '"');
},
serialize : function (data) {
if (typeof data == 'object') {
var arr = [];
for (var name in data) {
arr.push(name + '=' + Aak.encodeURI(data[name]));
}
return arr.join('&');
}
return data;
},
unserialize : function (str) {
var str = Aak.decodeHTML(str);
var arr = str.split('&');
var obj = {};
arr.forEach(function (entry) {
if (entry != '' && entry.split('=')) {
var splits = entry.split('=');
obj[splits[0]] = Aak.decodeURI(splits[1]);
}
});
return obj;
},
delProperty : function (obj, props) {
var props = (typeof props == 'string') ? props.split(',') : props;
for (var i = 0; i < props.length; i++) {
var prop = props[i];
if (obj.hasOwnProperty(prop)) {
delete obj[prop];
}
}
return obj;
},
setProperty : function (obj1, obj2) {
for (var prop in obj2) {
obj1[prop] = obj2[prop];
}
return obj1;
},
editSWF : function (so, opts) {
Aak.onElement(so, function () {
var original = Aak.getElement(so);
var clone = original.cloneNode(true);
if (opts.setAttributes) {
var obj = opts.setAttributes;
for (var p in obj) {
if (clone.querySelector('param[name="' + p + '"]')) {
clone.querySelector('param[name="' + p + '"]').value = obj[p];
} else if (clone.getAttribute(p)) {
clone.setAttribute(p, obj[p]);
}
}
}
if (opts.delAttributes) {
var obj = opts.delAttributes;
for (var p in obj) {
if (clone.querySelector('param[name="' + p + '"]')) {
Aak.removeElement(clone.querySelector('param[name="' + p + '"]'));
} else if (clone.getAttribute(p)) {
delete obj[p];
}
}
}
if (opts.setFlashvars || opts.delFlashvars) {
if (clone.querySelector('param[name="flashvars"]')) {
var param = clone.querySelector('param[name="flashvars"]');
var sFlashvars = param.value;
} else if (clone.getAttribute('flashvars')) {
var sFlashvars = clone.getAttribute('flashvars');
} else if (clone.getAttribute('data') && clone.getAttribute('data').indexOf('?') >= 0) {
var splits = clone.getAttribute('data').split('?', 2);
var swf = splits[0];
var sFlashvars = splits[1];
}
var oFlashvars = Aak.unserialize(sFlashvars);
Aak.log(oFlashvars);
if (opts.setFlashvars) {
oFlashvars = Aak.setProperty(oFlashvars, opts.setFlashvars);
}
if (opts.delFlashvars) {
oFlashvars = Aak.delProperty(oFlashvars, opts.delFlashvars);
}
var sFlashvars = Aak.serialize(oFlashvars);
if (param) {
param.value = sFlashvars;
} else if (swf) {
clone.setAttribute('data', swf + '?' + sFlashvars);
} else {
clone.setAttribute('flashvars', sFlashvars);
}
}
// replace
Aak.replaceElement(original, clone);
});
},
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
},
get : function (element) {
if (Aak.getElement(element)) {
this.in.node = Aak.getElement(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.generateID();
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);
},
log : function (a) {
Aak.log('Aak.player ' + a || '' + '');
Aak.log(this);
},
mergeObj : function (obj1, obj2) {
for (var prop in obj2) {
obj1[prop] = obj2[prop];
}
},
setVars : function (flashvars) {
if (typeof flashvars == 'string') {
this.flashvars.str = flashvars;
this.splitVars();
this.joinVars();
} else if (typeof flashvars == 'object') {
this.mergeObj(this.flashvars.obj, flashvars);
this.joinVars();
this.splitVars();
}
},
removeVars : function (str) {
var obj = this.flashvars.obj;
var splits = str.split(',');
for (var i = 0; i < splits.length; i++) {
var k = splits[i];
if (k in obj)
delete obj[k];
}
this.flashvars.obj = obj;
this.joinVars();
},
splitVars : function () {
var str = Aak.decodeHTML(this.flashvars.str);
var arr = str.split('&');
var obj = {};
for (var i = 0; i < arr.length; i++) {
var k = arr[i];
if (k != '' && k.split('=')) {
var s = k.split('=');
obj[s[0]] = Aak.decodeURI(s[1]);
}
}
this.flashvars.obj = obj;
},
joinVars : function () {
var obj = this.flashvars.obj;
var arr = [];
for (var k in obj) {
arr.push(k + '=' + Aak.encodeURI(obj[k])); // encodeURIComponent
}
this.flashvars.str = arr.join('&'); // &
},
insert : function () {
//
this.swfvars = [this.attributes.src, this.flashvars.str].join('?');
switch (this.options.output) {
case 'iframe':
this.out.node = document.createElement('iframe');
this.out.node.setAttribute('src', this.swfvars);
this.out.node.setAttribute('width', this.attributes.width + 10);
this.out.node.setAttribute('height', this.attributes.height + 10);
this.out.node.setAttribute('frameborder', 0);
this.out.node.setAttribute('scrolling', 'no');
this.out.node.setAttribute('allowfullscreen', true); // http://tinyurl.com/oyyehab
// allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen
break;
case 'tab':
return Aak.openInTab(this.swfvars);
break;
case 'html5':
this.out.node = document.createElement('video');
this.out.node.innerHTML = '<strong>Video not playing ? <a href="' + this.attributes.src + '" download>Download file</a> instead.</strong>';
for (var name in this.attributes) {
this.out.node.setAttribute(name, this.attributes[name]);
}
/*
if (this.attributes.autoplay) { // fix bug duplicate playing on firefox/chrome
this.out.node.onloadstart = function () {
this.play();
};
}*/
this.out.node.onerror = function () { // switch to plugin player
setTimeout(function () {
Aak.player.plugin(this, {
file : Aak.player.attributes.src
}, 3e3);
});
};
break;
default:
this.out.node = document.createElement('embed');
for (var name in this.attributes) {
this.out.node.setAttribute(name, this.attributes[name]);
}
if (this.flashvars.str) {
this.out.node.setAttribute('flashvars', this.flashvars.str);
}
}
this.out.html = this.getHtml(this.out.node);
this.out.tag = this.out.node.tagName;
if (this.options.output == 'inner') {
this.in.node.innerHTML = this.out.html;
} else { // replace
this.in.parent.replaceChild(this.out.node, this.in.node);
}
this.log('done');
},
getHtml : function (node) {
var tmp = document.createElement('div');
tmp.appendChild(node.cloneNode(true))
return tmp.innerHTML;
},
getMime : function (file) {
var mime = file.match(/\.(flv|mp4|webm|ogv|ogg|mp3|mpeg|mpg|mkv|avi|mov)$/);
if (mime && mime.length == 2) {
return 'video/' + mime[1];
} else {
return 'video/mp4';
}
},
jwplayer5 : function (id, setup) {
// Jwplayer 5 (flash)
// support: http://tinyurl.com/mjavxdr
// mp4, m4v, f4v, mov, flv, webm, aac, mp3, vorbis, hls, rtmp, youtube, aac, m4a, f4a, mp3, ogg, oga
this.get(id);
this.nameplayer = 'jwplayer5';
this.attributes.src = "http://player.longtailvideo.com/player5.9.swf"; // v5.9
this.attributes.src = "http://player.longtailvideo.com/player.swf"; // v5.10
this.attributes.height = setup.height || this.in.node.clientHeight || "100%";
this.attributes.width = setup.width || this.in.node.clientWidth || "100%";
setup.abouttext = 'Anti-Adblock Killer';
setup.aboutlink = 'https://github.com/reek/anti-adblock-killer';
this.mergeObj(this.flashvars.obj, setup);
this.flashvars.obj.controlbar = 'over';
if (setup.skin) {
this.flashvars.obj.skin = 'http://www.longtailvideo.com/files/skins/' + setup.skin + '/5/' + setup.skin + '.zip';
}
this.joinVars();
this.options.output = 'embed';
this.insert();
},
flowplayer : function (id, setup) {
// Flowplayer (flash)
// support: mp4, flv, f4v, m4v, mov
// Config: http://tinyurl.com/na7vy7b
this.get(id);
this.nameplayer = 'flowplayer';
this.attributes.src = "http://releases.flowplayer.org/swf/flowplayer-3.2.18.swf";
this.attributes.height = setup.clip && setup.clip.height || this.in.node.clientHeight || "100%";
this.attributes.width = setup.clip && setup.clip.width || this.in.node.clientWidth || "100%";
setup.autoPlay = setup.clip && setup.clip.autostart;
setup.url = setup.clip && setup.clip.file;
this.flashvars.obj = {
config : JSON.stringify(setup)
};
this.flashvars.str = 'config=' + JSON.stringify(setup);
this.options.output = 'embed';
this.insert();
},
videojs : function (id, setup) {
//http://tinyurl.com/pcgx2ob
//http://tinyurl.com/nscztmm
//http://jsfiddle.net/N8Zs5/18/
this.get(id);
this.nameplayer = 'videoJs';
setup.autostart = setup.autostart || false;
setup.height = setup.height || this.attributes.height;
setup.width = setup.width || this.attributes.width;
setup.type = this.getMime(setup.file || setup.src);
setup.id = setup.id || Aak.generateID();
var html = '<html><head><link href="http://vjs.zencdn.net/4.8/video-js.css" rel="stylesheet"><script src="http://vjs.zencdn.net/4.8/video.js"></script></head><body><video id="' + setup.id + '" class="video-js vjs-default-skin vjs-big-play-centered" controls preload="auto" width="' + setup.width + '" height="' + setup.height + '"></video><script>videojs("' + setup.id + '",{techOrder:["flash","html5"],autoplay:' + setup.autostart + ',sources:[{type:"' + setup.type + '",src:"' + setup.file + '"}]})</script></body></html>';
this.attributes.src = "data:text/html;charset=utf-8," + escape(html);
this.options.output = 'iframe';
this.insert();
},
jwplayer6 : function (id, setup) {
// Jwplayer 6 (flash)
// Config: http://tinyurl.com/lcygyu9
// Iframe: http://tinyurl.com/86agg68
this.get(id);