ABPVN AdsBlock

Script block ads, remove wating of ABPVN

От 03.10.2019. Виж последната версия.

  1. // ==UserScript==
  2. // @name ABPVN AdsBlock
  3. // @namespace ABPVN
  4. // @author ABPVN
  5. // @copyright ABPVN
  6. // @homepage https://abpvn.com
  7. // @supportURL https://github.com/abpvn/abpvn/issues
  8. // @icon https://abpvn.com/icon.png
  9. // @description Script block ads, remove wating of ABPVN
  10. // @description:vi Script chặn quảng cáo,loại bỏ chờ đợi của ABPVN
  11. // @contributionURL https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=donghoang.nguyen@gmail.com&item_name=ABPVN Donation
  12. // @grant GM_getValue
  13. // @grant GM_setValue
  14. // @grant GM_openInTab
  15. // @grant GM_registerMenuCommand
  16. // @include http://*
  17. // @include https://*
  18. // @version     2.2.63
  19. // @change-log Remove fake link of https://banthang.tv/
  20. // @run-at document-end
  21. // ==/UserScript==
  22. /* String Prototype */
  23. String.prototype.startWith = function (str) {
  24. return typeof this.indexOf === 'function' && this.indexOf(str) === 0;
  25. };
  26. String.prototype.ismatch = function (regex) {
  27. return typeof this.match === 'function' && this.match(regex) !== null;
  28. };
  29. //Bypass Class
  30. var byPass = {
  31. hideLinkUnlock: function () {
  32. var contentDiv = document.querySelectorAll('.onp-sl-content,.onp-locker-call,[data-locker-id]');
  33. if (contentDiv.length) {
  34. ABPVN.cTitle();
  35. //Add style tag to hide all .onp-sl and show all .onp-sl-content
  36. if (!document.getElementById('abpvn_style')) {
  37. var style = document.createElement('style');
  38. style.id = 'abpvn_style';
  39. style.innerHTML = '.onp-sl-content{display:block!important;}.onp-sl,.onp-sl-overlap-box{display:none!important;}.onp-sl-blur-area{filter: none!important;}';
  40. document.body.appendChild(style);
  41. } //ShowALl ContentDiv
  42. for (var i in contentDiv) {
  43. if (contentDiv[i].firstChild && contentDiv[i].firstChild.innerText != 'Unlocked by ABPVN.COM') {
  44. var creditDiv = document.createElement('div');
  45. creditDiv.innerHTML = '<a href="http://abpvn.com" target="_blank" style="color: #08BE54;font-weight: bold;">Unlocked by ABPVN.COM</a>';
  46. creditDiv.style.textAlign = 'right';
  47. contentDiv[i].insertBefore(creditDiv, contentDiv[i].firstChild);
  48. }
  49. if (contentDiv[i].style) {
  50. contentDiv[i].style.display = 'block';
  51. }
  52. } //Hide All LockDiv
  53. var lockDiv = document.querySelectorAll('.onp-sl,div[id^="content-locker"]');
  54. for (var j in lockDiv) {
  55. if (lockDiv[j].style) {
  56. lockDiv[j].style.display = 'none !important';
  57. lockDiv[j].setAttribute('hidden', 'hidden');
  58. }
  59. }
  60. }
  61. },
  62. removeShortLink: function () {
  63. var allShortLink = document.querySelectorAll('a[href*="/full/?api="]');
  64. var count = 0;
  65. if (allShortLink.length) {
  66. ABPVN.cTitle();
  67. for (var i = 0; i < allShortLink.length; i++) {
  68. var processingLink = allShortLink[i];
  69. var href = processingLink.getAttribute('href');
  70. var tmp = href.match(/url=(.+?)&|$/);;
  71. if (tmp[1]) {
  72. processingLink.setAttribute('href', atob(tmp[1].replace(/=+$/, '')));
  73. var oldTitle = processingLink.getAttribute('title');
  74. processingLink.setAttribute('title', oldTitle ? (oldTitle + ' ') : '' + 'Short link by pass by ABPVN.COM');
  75. count++;
  76. }
  77. }
  78. Logger.info("By pass " + count + " short link");
  79. }
  80. },
  81. quickByPassLink: function () {
  82. var regex = /123link\..*|phlame.pw|mshare\.io|megaurl\.*|licklink.net|www.123l\.*|vinaurl\.*|share4you.pro|doxeaz10.site|derow.win/;
  83. var largeTimeoutHost = /licklink.net|share4you.pro|derow.win/;
  84. var autoCaptchaOnlyList = /megaurl\.*|vinaurl\.*|doxeaz10.site/;
  85. if (regex.test(location.hostname)) {
  86. try {
  87. var checkClick = function (mutation) {
  88. if (mutation.attributeName === "disabled" && !mutation.target.disabled) {
  89. return true;
  90. }
  91. if (mutation.attributeName === "class" && !mutation.target.classList.contains('disabled')) {
  92. return true;
  93. }
  94. return false;
  95. }
  96. // Set up a new observer
  97. var observer = new MutationObserver(function (mutations) {
  98. mutations.forEach(function (mutation) {
  99. // Check the modified attributeName is "disabled"
  100. if (checkClick(mutation)) {
  101. mutation.target.click();
  102. }
  103. if (mutation.attributeName === "href") {
  104. var link = mutation.target.getAttribute("href");
  105. document.body.innerHTML = '<style>h1{color: #00dc58;}a{color: #015199}a h1{color: #015199;}</style><center><h1>ABPVN quick bypass đã hoạt động</h1><a href=\'https://abpvn.com/donate\'><h1>Ủng hộ ABPVN</h1></a><br/>Không tự chuyển trang? <a href=\'' + link + '\' title=\'Chuyển trang\'>Click vào đây</a></center>';
  106. location.href = link;
  107. }
  108. });
  109. });
  110. // Configure to only listen to attribute changes
  111. var config = {
  112. attributes: true
  113. };
  114. var button = document.getElementById('invisibleCaptchaShortlink') || document.querySelector('.download_1');
  115. if (button) {
  116. observer.observe(button, config);
  117. } else {
  118. var getLink = document.querySelector('.get-link');
  119. var timeout = largeTimeoutHost.test(location.hostname) ? 6000 : 100;
  120. if (getLink) {
  121. observer.observe(getLink, config);
  122. if (!autoCaptchaOnlyList.test(location.hostname)) {
  123. setTimeout(function () {
  124. $("#go-link").addClass("go-link").trigger("submit.adLinkFly.counterSubmit").one("submit.adLinkFly.counterSubmit", function (e) {
  125. e.preventDefault();
  126. if (!largeTimeoutHost.test(location.hostname)) {
  127. location.reload();
  128. }
  129. });
  130. }, timeout);
  131. }
  132. }
  133. }
  134. // mshare.io
  135. var downloadButton = document.querySelector('#download-file-button');
  136. if (downloadButton) {
  137. $.ajax({
  138. url: '/download/get-download-info',
  139. type: 'POST',
  140. data: {
  141. id: downloadButton.getAttribute('data-id')
  142. },
  143. success: function (data) {
  144. if (data.success && data.file_info && data.file_info.href) {
  145. var link = data.file_info.href;
  146. document.body.innerHTML = '<style>h1{color: #00dc58;}a{color: #015199}a h1{color: #015199;}</style><center><h1>ABPVN quick download đã hoạt động</h1><a href=\'https://abpvn.com/donate\'><h1>Ủng hộ ABPVN</h1></a><br/>Không tự tải xuống? <a href=\'' + link + '\' title=\'Tải xuống\'>Click vào đây</a></center>';
  147. location.href = link;
  148. } else {
  149. location.reload();
  150. }
  151. },
  152. error: function () {
  153. location.reload();
  154. }
  155. });
  156. }
  157. } catch (e) {
  158. Logger.error(e);
  159. }
  160. }
  161. },
  162. wikiall_org: function () {
  163. if (location.hostname == 'wikiall.org' && document.querySelector('#timer')) {
  164. var observer = new MutationObserver(function (mutations) {
  165. mutations.forEach(function (mutation) {
  166. // Check the modified childList of place
  167. if (mutation.type == 'childList') {
  168. var targetA = mutation.target.querySelector('a');
  169. location.href = targetA.getAttribute('href');
  170. }
  171. });
  172. });
  173. // Configure to only listen to attribute changes
  174. var place = document.querySelector('#place');
  175. observer.observe(place, {
  176. childList: true
  177. });
  178. }
  179. },
  180. init: function () {
  181. if (configure.getValue('unlock_content', true)) {
  182. window.addEventListener('DOMContentLoaded', this.hideLinkUnlock);
  183. window.addEventListener('load', this.hideLinkUnlock);
  184. this.hideLinkUnlock();
  185. }
  186. if (configure.getValue('remove_short_link', true)) {
  187. window.addEventListener('DOMContentLoaded', this.removeShortLink);
  188. }
  189. if (configure.getValue('quick_by_pass_link', true)) {
  190. this.quickByPassLink();
  191. this.wikiall_org();
  192. }
  193. }
  194. };
  195. //Logger Class
  196. var Logger = {
  197. style: 'color: #00DC58',
  198. info: function (text) {
  199. console.info('%cABPVN.COM Info: ', this.style, text);
  200. },
  201. warn: function (text) {
  202. console.warn('%cABPVN Warn: ', this.style, text);
  203. },
  204. error: function (text) {
  205. console.error('%cABPVN Error: ', this.style, text);
  206. },
  207. log: function (text) {
  208. console.log('%cABPVN Log: ', this.style, text);
  209. },
  210. };
  211. //get Link class
  212. var getLink = {
  213. settingKey: 'fshare_download',
  214. FShareConfig: function () {
  215. if (this.url.startWith('https://www.fshare.vn')) {
  216. var currentSetting = configure.getValue(this.settingKey, true);
  217. var background_image = !currentSetting ? 'url("http://i.imgur.com/kJnOMOB.png")' : 'url("http://i.imgur.com/2b7fN6a.png")';
  218. var title = currentSetting ? 'Bật get link fshare' : 'Tắt get link fshare';
  219. var html = '<div id=\'fs_click\' title=\'' + title + '\' style=\'position: fixed; right: 0; bottom: 0; width: 30px; height: 30px; border-radius: 50%; background-image: ' + background_image + '; background-size: cover; cursor: pointer; z-index: 99999;\'></div>';
  220. $(document).ready(function () {
  221. $(document.body).append(html);
  222. $(document).on('click', '#fs_click', function FS_on_off() {
  223. if (currentSetting) {
  224. currentSetting = false;
  225. this.style.backgroundImage = 'url("http://i.imgur.com/kJnOMOB.png")';
  226. this.setAttribute('title', 'Bật get link fshare');
  227. alert('Đã tắt get link fshare');
  228. } else {
  229. currentSetting = true;
  230. this.setAttribute('title', 'Tắt get link fshare');
  231. this.style.backgroundImage = 'url("http://i.imgur.com/2b7fN6a.png")';
  232. alert('Đã bật get link fshare');
  233. }
  234. configure.setValue("fshare_download", currentSetting);
  235. });
  236. });
  237. }
  238. },
  239. FShareGetLink: function () {
  240. if (this.url.startWith('https://www.fshare.vn/file/') && !this.url.startWith('https://www.fshare.vn/file/manager')) {
  241. var currentSetting = configure.getValue(this.settingKey, true);
  242. if (currentSetting) {
  243. console.info('Start get link Fshare.vn');
  244. $(document).ready(function () {
  245. var checkpassword = document.querySelector('.password-form');
  246. var linkcode = $('#linkcode').val();
  247. if (checkpassword === null) {
  248. var code = $('#form-download input[name="_csrf-app"]').val();
  249. var data = {
  250. '_csrf-app': code,
  251. 'fcode5': '',
  252. 'linkcode': linkcode,
  253. 'withFcode5': 0,
  254. };
  255. $.post('/download/get', data).done(function (data, statusText, xhr) {
  256. if (data.url === undefined) location.reload();
  257. else {
  258. if (typeof location != 'undefined') {
  259. Logger.log(location.href + ' -> ' + data.url);
  260. var count_time = data.wait_time;
  261. var interval = setInterval(function () {
  262. var msg = "Cần đợi <span style='color: #cd1417'>" + count_time + "</span> giây nữa";
  263. document.querySelector('.d-info-container .thumbnail').innerHTML = "<div style='font-size: 25px;color: #00dc58;font-weight: bold'>ABPVN Auto download:<br/>" + msg + "</div>";
  264. count_time--;
  265. if (count_time <= 0) {
  266. clearInterval(interval);
  267. location.href = data.url;
  268. }
  269. }, 1000);
  270. } else {
  271. $('.download').prepend('<a title="Tải trực tiếp" style="padding: 5px 0;box-sizing: content-box;" class="download-btn mdc-button mdc-button--raised mdc-ripple-upgraded full-width mdc-button-primary fcode5" href="' + data.url + '">Tải trực tiếp<span>Hỗ trợ bởi abpvn.com</span></a>');
  272. }
  273. }
  274. }).fail(function (xhr, statusText, error) {
  275. alert('ABPVN: Đã có lỗi fshare hoặc file có password');
  276. });
  277. } else {
  278. alert('ABPVN: Hãy nhập mật khẩu cho file trước');
  279. }
  280. });
  281. } else {
  282. $('.download').prepend('<a title="Download nhanh qua linksvip.net" style="padding: 5px 0;box-sizing: content-box; margin: 5px auto;background-color: #00dc58;" class="download-btn mdc-button mdc-button--raised mdc-ripple-upgraded full-width mdc-button-primary fcode5" href="http://linksvip.net?link=' + location.href + '">Tải nhanh<span>Qua dịch vụ linksvip.net</span></a>');
  283. $('.download').prepend('<a title="Download nhanh qua getlinkaz.com" style="padding: 5px 0;margin: 5px auto;box-sizing: content-box;background-color: #00dc58;" class="download-btn mdc-button mdc-button--raised mdc-ripple-upgraded full-width mdc-button-success fcode5" href="https://vnz-leech.com?link=' + location.href + '">Tải nhanh<span>Qua dịch vụ vnz-leech.com</span></a>');
  284. }
  285. }
  286. },
  287. vnz_leech_auto_fill: function () {
  288. if (this.url == 'https://www4.cbox.ws/box/?boxid=4240872&boxtag=soigia&sec=form' && this.url.indexOf('link=')) {
  289. var url = (window.location != window.parent.location) ?
  290. document.referrer :
  291. document.location.href;
  292. var match = url.match(/link=([\w\.\/\:]+)($|&|\?)/);
  293. if (match) {
  294. document.querySelector('input[name="pst"]').value = match[1];
  295. }
  296. }
  297. },
  298. mediafire_com: function () {
  299. if (this.url.startWith('http://www.mediafire.com/file/') || this.url.startWith('https://www.mediafire.com/file/')) {
  300. var a_tag = document.querySelector('.download_link a.input');
  301. var link = a_tag.getAttribute('href');
  302. if (link.startWith('http')) {
  303. document.body.innerHTML = '<style>h1{color: #00dc58;}a{color: #015199}a h1{color: #015199;}</style><center><h1>ABPVN MediaFire Download đã hoạt động</h1><a href=\'https://abpvn.com/donate\'><h1>Ủng hộ ABPVN</h1></a><br/>Không tự tải xuống? <a href=\'' + link + '\' title=\'Download\'>Click vào đây</a></center>';
  304. location.href = link;
  305. }
  306. }
  307. },
  308. usercloud_com: function () {
  309. if (this.url.startWith('https://userscloud.com/') && this.url.length > 24) {
  310. var form = document.querySelector('form[name="F1"]');
  311. if (form) {
  312. form.submit();
  313. document.body.innerHTML = '<style>h1{color: #00dc58;}a{color: #015199}a h1{color: #015199;}</style><center><h1>ABPVN UserCloud Download đã hoạt động</h1><a href=\'https://abpvn.com/donate\'><h1>Ủng hộ ABPVN</h1></center>';
  314. } else {
  315. var a_link = document.querySelector('h4 a.btn-success');
  316. if (a_link) {
  317. var link = a_link.getAttribute('href');
  318. if (link.startWith('https')) {
  319. document.body.innerHTML = '<style>h1{color: #00dc58;}a{color: #015199}a h1{color: #015199;}</style><center><h1>ABPVN UserCloud Download đã hoạt động</h1><a href=\'https://abpvn.com/donate\'><h1>Ủng hộ ABPVN</h1></a><br/>Không tự tải xuống? <a href=\'' + link + '\' title=\'Download\'>Click vào đây</a></center>';
  320.  
  321. }
  322. }
  323. }
  324. }
  325. },
  326. init: function () {
  327. this.url = location.href;
  328. this.FShareConfig();
  329. this.FShareGetLink();
  330. if (configure.getValue('quick_download', true)) {
  331. this.mediafire_com();
  332. this.usercloud_com();
  333. this.vnz_leech_auto_fill();
  334. }
  335. }
  336. };
  337. //Fix site class
  338. var fixSite = {
  339. elementExist: function (selector) {
  340. var check = document.querySelector(selector);
  341. return check != null;
  342. },
  343. getAllText: function (selector) {
  344. var text = '';
  345. var nodeList = document.querySelectorAll(selector);
  346. if (nodeList) {
  347. for (var i in nodeList) {
  348. if (nodeList[i].innerText) text += nodeList[i].innerText;
  349. }
  350. }
  351. return text;
  352. },
  353. getScript: function (url) {
  354. var xhr = new XMLHttpRequest();
  355. xhr.open('GET', url);
  356. xhr.addEventListener('load', function (data) {
  357. var blob = new Blob([xhr.responseText], {
  358. type: 'text/javascript'
  359. });
  360. var url = URL.createObjectURL(blob);
  361. var script = document.createElement('script');
  362. script.src = url;
  363. script.type = 'text/javascript';
  364. document.getElementsByTagName('head')[0].appendChild(script);
  365. });
  366. xhr.send();
  367. },
  368. loadCss: function (url, id) {
  369. var css_tag = document.createElement('link');
  370. css_tag.rel = 'stylesheet';
  371. css_tag.id = id;
  372. css_tag.href = url;
  373. var head = document.getElementsByTagName('head')[0];
  374. head.appendChild(css_tag);
  375. },
  376. phimmedia_tv: function () {
  377. if (this.url.startWith('https://www.phimmedia.tv/') || this.url.startWith('http://www.phimmedia.tv/')) {
  378. var links = document.querySelectorAll('#btn-film-watch,.poster > a');
  379. if (links) {
  380. for (var i = 0; i < links.length; i++) {
  381. var href = links[i].getAttribute('href');
  382. href = href.match('utm_id=.*')[0].replace('utm_id=', '');
  383. if (href) {
  384. links[i].setAttribute('href', atob(href));
  385. }
  386. }
  387. ABPVN.cTitle();
  388. }
  389. }
  390. },
  391. linkneverdie_com: function () {
  392. if (this.url.startWith('https://linkneverdie.com/')) {
  393. ABPVN.cTitle();
  394. var el = document.getElementById('wrapper');
  395. if (el) {
  396. el.id = "wrapper-fix-by-abpvn";
  397. }
  398. //Hide ads image
  399. var aTag = document.querySelector('#adsqca');
  400. if (aTag) {
  401. aTag.setAttribute('style', 'display:none !important');
  402. }
  403. }
  404. },
  405. hdonline_vn: function () {
  406. if (this.url.startWith('http://hdonline.vn')) {
  407. var links = document.querySelectorAll('a[href^="http://hub.blueserving.com/"]');
  408. for (var i in links) {
  409. var link = links[i];
  410. var href = link.getAttribute('href');
  411. href = href.match('url=.*')[0].replace('url=', '');
  412. if (href) {
  413. link.setAttribute('href', href);
  414. }
  415. }
  416. ABPVN.cTitle();
  417. }
  418. },
  419. maclife_vn: function () {
  420. if (this.url.startWith('https://maclife.vn/')) {
  421. var allShortUrl = document.querySelectorAll('a[rel]');
  422. var count = 0;
  423. for (var i = 0; i < allShortUrl.length; i++) {
  424. if (allShortUrl[i].innerText.indexOf('http') === 0) {
  425. allShortUrl[i].setAttribute('href', allShortUrl[i].innerText);
  426. count++;
  427. }
  428. }
  429. Logger.info("Đã xóa " + count + " link rút gọn!");
  430. }
  431. },
  432. aphim_co: function () {
  433. if (this.url.startWith('https://aphim.co/xem-phim/')) {
  434. ABPVN.cTitle();
  435. var aTagAds = document.querySelector('#video > a');
  436. aTagAds.setAttribute('href', '#abpvn');
  437. aTagAds.removeAttribute('target');
  438. Logger.info('Đã xóa link quảng cáo!');
  439. }
  440. },
  441. openload: function () {
  442. if (this.url.match(/^(https?:)?\/\/openload\.co\/*.*/) || this.url.match(/^(https?:)?\/\/oload\.\/*.*/)) {
  443. //Base on https://greasyfork.org/vi/scripts/17665-openload
  444. //
  445. // @run-at document-start
  446. //
  447. window.adblock = false;
  448. window.adblock2 = false;
  449. window.turnoff = true;
  450. window.open = function () { };
  451. //
  452. // @run-at document-end
  453. //
  454. function onready(fn) {
  455. if (document.readyState != 'loading') fn();
  456. else document.addEventListener('DOMContentLoaded', fn);
  457. }
  458. onready(function () {
  459. if (document.location.href.match(/\/embed\//) || $('#realdl>a')) {
  460. $('#btnView').hide();
  461. $('#btnDl').hide();
  462. $('.dlButtonContainer').show();
  463. $('h3.dlfile.h-method').hide();
  464. $('.col-md-4.col-centered-sm *').remove();
  465. $('#mgiframe,#main>div[id*="Composite"]').remove();
  466. $('#downloadTimer').hide();
  467. $('#mediaspace_wrapper').prepend($('<div/>').attr('id', 'realdl')
  468. .attr('style', 'position: absolute; top: 0 ; left: 0 ; right: 0; text-align: center; z-index: 9999; background-color: #00DC58; padding: .5em 0;')
  469. .on('mouseenter', function () {
  470. $(this).fadeTo(500, 1);
  471. }).on('mouseleave', function () {
  472. $(this).fadeTo(500, 0);
  473. })
  474. .append($('<a/>').attr('href', '').attr('style', 'color: #fff; text-decoration: none;').html('FREE DOWNLOAD<sub>Power by abpvn.com</sub>')));
  475. if (document.location.href.match(/\/embed\//)) {
  476. setTimeout(function () {
  477. $('#realdl').fadeTo(500, 0);
  478. }, 1500);
  479. }
  480. $('#realdl').show();
  481. var streamurl_tmr = setInterval(function () {
  482. // <@snippet author="https://greasyfork.org/forum/profile/daedelus" src="https://greasyfork.org/forum/discussion/36362/x">
  483. var streamurl_src;
  484. $('p[id]').each(function () {
  485. streamurl_src = streamurl_src || ($(this).text().match(/^[\w\.~-]+$/) && $(this).text().match(/~/)) ? $(this).text() : streamurl_src;
  486. });
  487. // </@snippet>
  488. if (streamurl_src) {
  489. var streamurl_url = location.origin + '/stream/' + streamurl_src;
  490. $('#realdl a').attr('href', streamurl_url);
  491. $('#steamcopy').text(streamurl_url);
  492. $('#videooverlay').click();
  493. clearInterval(streamurl_tmr);
  494. }
  495. }, 100);
  496. }
  497. window.onclick = function () { };
  498. document.onclick = function () { };
  499. document.body.onclick = function () { };
  500. });
  501. }
  502. },
  503. fontdep_com: function () {
  504. if (this.url.startWith('http://www.fontdep.com/') && document.cookie.indexOf('virallock_myid') == -1) {
  505. document.cookie = 'virallock_myid=0001';
  506. location.reload();
  507. }
  508. },
  509. fakelinkRemover: function () {
  510. if (this.url.startWith('https://ibongda.tv') || this.url.startWith('https://thevang.tv') || this.url.startWith('https://banthang.tv/')) {
  511. ABPVN.cTitle();
  512. var fakeLink = document.querySelectorAll('a[data-href][rel="nofollow"],a[data-url][rel="nofollow"]');
  513. var count = 0;
  514. for (var i = 0; i < fakeLink.length; i++) {
  515. if (fakeLink[i]) {
  516. fakeLink[i].setAttribute('href', fakeLink[i].getAttribute('data-href') || fakeLink[i].getAttribute('data-url'));
  517. count++;
  518. }
  519. }
  520. Logger.info("Removed " + count + " fake link in " + location.hostname);
  521. }
  522. },
  523. antiAdblockRemover: function () {
  524. var msg = 'By pass adBlock detect rồi nhé! Hahahahaha 😁😁😁';
  525. if (typeof adBlockDetected === 'function') {
  526. adBlockDetected = function () {
  527. Logger.info(msg);
  528. };
  529. }
  530. if (typeof showAdsBlock === 'function') {
  531. showAdsBlock = function () {
  532. Logger.info(msg);
  533. };
  534. }
  535. },
  536. kickass_best: function () {
  537. if (this.url.startWith('https://kickass.best')) {
  538. var allFakeA = document.querySelectorAll('a[href^="https://mylink.cx/?url="]');
  539. var count = 0;
  540. for (var i = 0; i < allFakeA.length; i++) {
  541. var aTag = allFakeA[i];
  542. if (aTag) {
  543. var realLink = aTag.getAttribute('href').replace(/https:\/\/mylink\.cx\/\?url=(.*)/, '$1');
  544. aTag.setAttribute('href', decodeURIComponent(realLink));
  545. count++;
  546. }
  547. }
  548. Logger.info("Removed " + count + " fake link in " + location.hostname);
  549. }
  550. },
  551. removeRedir: function (config) {
  552. if (this.url.match(new RegExp(config.url, 'g')) || this.url.startWith(config.url)) {
  553. ABPVN.cTitle();
  554. var links = document.querySelectorAll(config.selector || 'a[href^="' + config.replace + '"]');
  555. Logger.info('Remove Redirect for ' + links.length + ' links');
  556. if (links.length) {
  557. links.forEach(function (item) {
  558. var stockUrl = item.getAttribute('href').replace(config.replace, '');
  559. var count = 0;
  560. while (stockUrl.indexOf('%2') > -1 && count < 5) {
  561. stockUrl = decodeURIComponent(stockUrl);
  562. count++;
  563. }
  564. item.setAttribute('href', stockUrl);
  565. item.setAttribute('title', 'Link đã xóa chuyển hướng trung gian bởi abpvn.com');
  566. }.bind(this));
  567. }
  568. }
  569. },
  570. removeRedirect() {
  571. var configs = [{
  572. url: 'https://samsungvn.com',
  573. replace: 'https://samsungvn.com/xfa-interstitial/redirect?url=',
  574. },
  575. {
  576. url: 'https://forum.vietdesigner.net',
  577. replace: 'redirect/?url='
  578. },
  579. {
  580. url: 'http://sinhvienit.net',
  581. replace: 'http://sinhvienit.net/goto/?'
  582. },
  583. {
  584. url: 'http://phanmemaz.com/',
  585. replace: 'http://phanmemaz.com/wp-content/plugins/tm-wordpress-redirection/l.php?'
  586. },
  587. {
  588. url: 'forums.voz.vn/showthread.php',
  589. replace: '/redirect/index.php?link='
  590. },
  591. {
  592. url: 'www.webtretho.com/forum/',
  593. replace: /http(s?):\/\/webtretho\.com\/forum\/links\.php\?url=/,
  594. selector: 'a[href*="webtretho.com/forum/links.php?url="]'
  595. }
  596. ];
  597. configs.forEach(function (config) {
  598. this.removeRedir(config);
  599. }.bind(this));
  600. },
  601. init: function () {
  602. this.url = location.href;
  603. if (configure.getValue('remove_redirect', true)) {
  604. this.removeRedirect();
  605. }
  606. this.antiAdblockRemover();
  607. this.phimmedia_tv();
  608. this.linkneverdie_com();
  609. this.hdonline_vn();
  610. this.maclife_vn();
  611. this.aphim_co();
  612. this.fontdep_com();
  613. this.openload();
  614. this.kickass_best();
  615. this.fakelinkRemover();
  616. }
  617. };
  618. //Ad blocker script
  619. var adBlocker = {
  620. blockPopUp: function () {
  621. var listSite = [
  622. 'blogtruyen.com',
  623. 'www.khosachnoi.net',
  624. 'hamtruyen.vn',
  625. 'phim14.net',
  626. 'phim7.com',
  627. 'www.diendan.trentroiduoidat.com',
  628. 'www.trentroiduoidat.com',
  629. 'chophanthiet.us',
  630. 'animetvn.com',
  631. 'font.vn',
  632. 'vidoza.net',
  633. 'www.easysoft.xyz',
  634. 'hdonline.vn',
  635. 'www.phim.media',
  636. 'phimnhanh.com',
  637. 'www.vietsubhd.com',
  638. 'www.phimmedia.tv',
  639. 'tvhay.org',
  640. 'bilutv.org'
  641. ];
  642. for (var i = 0; i < listSite.length; i++) {
  643. if (location.hostname === listSite[i]) {
  644. ABPVN.cTitle();
  645. Logger.info('Đã chặn popup quảng cáo');
  646. document.body.onclick = null;
  647. document.onclick = null;
  648. document.ontouchstart = null;
  649. document.onmousedown = null;
  650. window.addEventListener('load', function () {
  651. setTimeout(function () {
  652. Logger.info('Đã chặn popup quảng cáo onload');
  653. document.ontouchstart = null;
  654. document.onclick = null;
  655. document.body.onclick = null;
  656. document.onmousedown = null;
  657. }, 300);
  658. });
  659. window.addEventListener('DOMContentLoaded', function () {
  660. setTimeout(function () {
  661. Logger.info('Đã chặn popup quảng cáo dom load');
  662. document.ontouchstart = null;
  663. document.onclick = null;
  664. document.body.onclick = null;
  665. document.onmousedown = null;
  666. }, 300);
  667. });
  668. }
  669. }
  670. },
  671. mgIdAdRemover: function () {
  672. var allMgIdEl = document.querySelectorAll('[id*="ScriptRoot"]');
  673. if (allMgIdEl && allMgIdEl.length) {
  674. ABPVN.cTitle();
  675. for (var i = 0; i < allMgIdEl.length; i++) {
  676. allMgIdEl[i].id = 'ScriptRoot-removed-by-abpvn-' + Math.random();
  677. allMgIdEl[i].innerHTML = '';
  678. }
  679. }
  680. },
  681. phimnhanh_com: function () {
  682. if (this.url.startWith('http://phimnhanh.com/xem-phim')) {
  683. Logger.warn('Đã chặn video preload');
  684. if (video !== undefined) {
  685. video.preroll = function (options) { };
  686. }
  687. }
  688. },
  689. vinaurl_net: function () {
  690. if (this.url.match(/vinaurl\.*/)) {
  691. document.querySelectorAll('div[id^="ads-"]').forEach(item => item.remove());
  692. }
  693. },
  694. init: function () {
  695. this.url = location.href;
  696. this.mgIdAdRemover();
  697. this.blockPopUp();
  698. this.phimnhanh_com();
  699. this.vinaurl_net();
  700. },
  701. };
  702. var configure = {
  703. urls: {
  704. setting: 'https://abpvn.com/script-setting.html',
  705. issue: 'https://github.com/abpvn/abpvn/issues/new',
  706. fanpage: 'https://www.facebook.com/abpvn.org',
  707. },
  708. openUrl: function (url) {
  709. if (typeof GM_openInTab === 'function') {
  710. GM_openInTab(url);
  711. }
  712. },
  713. getValue: function (key, defaultValue) {
  714. var value;
  715. if (typeof GM_getValue === 'function') {
  716. value = GM_getValue(key);
  717. }
  718. if (typeof value === 'undefined') {
  719. return defaultValue;
  720. }
  721. return value;
  722. },
  723. setValue: function (key, value) {
  724. if (typeof GM_setValue === 'function') {
  725. return GM_setValue(key, value);
  726. }
  727. },
  728. setUpSetting: function () {
  729. if (this.url === this.urls.setting) {
  730. var settingContainer = document.querySelector('#setting-container');
  731. if (settingContainer) {
  732. settingContainer.classList.add('installed');
  733. var allSetting = settingContainer.querySelectorAll('input[type="checkbox"]');
  734. if (allSetting) {
  735. allSetting.forEach(checkbox => {
  736. checkbox.checked = this.getValue(checkbox.name, true);
  737. checkbox.addEventListener('change', event => {
  738. var target = event.target;
  739. var key = target.name;
  740. this.setValue(key, event.target.checked);
  741. });
  742. });
  743. }
  744. }
  745. }
  746. },
  747. init: function () {
  748. this.url = location.href;
  749. if (typeof GM_registerMenuCommand === 'function') {
  750. GM_registerMenuCommand('ABPVN - Cài đặt', () => {
  751. this.openUrl(this.urls.setting);
  752. });
  753. GM_registerMenuCommand('ABPVN - Báo lỗi', () => {
  754. this.openUrl(this.urls.issue);
  755. });
  756. GM_registerMenuCommand('ABPVN - Fanpage', () => {
  757. this.openUrl(this.urls.fanpage);
  758. });
  759. }
  760. this.setUpSetting();
  761. }
  762. };
  763. //Main class
  764. var ABPVN = {
  765. cTitle: function () {
  766. if (document.title.indexOf(' - Fixed by ABPVN.COM') === -1) {
  767. document.title = document.title + ' - Fixed by ABPVN.COM';
  768. }
  769. },
  770. init: function () {
  771. //Init class adBlocker
  772. adBlocker.init();
  773. //Init class getLink
  774. getLink.init();
  775. //Init class Fixsite
  776. fixSite.init();
  777. //Init bypass class
  778. byPass.init();
  779. if (window === window.parent) {
  780. //Init Congfiure
  781. configure.init();
  782. }
  783. }
  784. };
  785. //RUN INNIT
  786. ABPVN.init();