Greasy Fork is available in English.

ABPVN AdsBlock

Script block ads, remove wating of ABPVN

Mint 2019.04.06.. Lásd a legutóbbi verzió

  1. // ==UserScript==
  2. // @name ABPVN AdsBlock
  3. // @namespace ABPVN
  4. // @author ABPVN
  5. // @copyright ABPVN
  6. // @homepage http://abpvn.com
  7. // @supportURL https://github.com/abpvn/abpvn/issues
  8. // @icon http://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.49
  19. // @change-log Add megaurl.in auto submit captcha
  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/;
  83. var largeTimeoutHost = /licklink.net/;
  84. var autoCaptchaOnlyList = /megaurl\.*/;
  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. location.href = mutation.target.getAttribute("href");
  105. }
  106. });
  107. });
  108. // Configure to only listen to attribute changes
  109. var config = {
  110. attributes: true
  111. };
  112. var button = document.getElementById('invisibleCaptchaShortlink') || document.querySelector('.download_1');
  113. if (button) {
  114. observer.observe(button, config);
  115. } else {
  116. var getLink = document.querySelector('.get-link');
  117. var timeout = largeTimeoutHost.test(location.hostname) ? 6000 : 100;
  118. if (getLink) {
  119. observer.observe(getLink, config);
  120. console.log(getLink);
  121. if (!autoCaptchaOnlyList.test(location.hostname)) {
  122. setTimeout(function() {
  123. $("#go-link").addClass("go-link").trigger("submit.adLinkFly.counterSubmit").one("submit.adLinkFly.counterSubmit", function(e) {
  124. e.preventDefault();
  125. if (!largeTimeoutHost.test(location.hostname)) {
  126. location.reload();
  127. }
  128. });
  129. }, timeout);
  130. }
  131. }
  132. }
  133. // mshare.io
  134. var downloadButton = document.querySelector('#download-file-button');
  135. if (downloadButton) {
  136. $.ajax({
  137. url: '/download/get-download-info',
  138. type: 'POST',
  139. data: {
  140. id: downloadButton.getAttribute('data-id')
  141. },
  142. success: function(data) {
  143. if (data.success && data.file_info && data.file_info.href) {
  144. location.href = data.file_info.href;
  145. } else {
  146. location.reload();
  147. }
  148. },
  149. error: function() {
  150. location.reload();
  151. }
  152. });
  153. }
  154. } catch (e) {
  155. Logger.error(e);
  156. }
  157. }
  158. },
  159. init: function() {
  160. if (configure.getValue('unlock_content', true)) {
  161. window.addEventListener('DOMContentLoaded', this.hideLinkUnlock);
  162. window.addEventListener('load', this.hideLinkUnlock);
  163. this.hideLinkUnlock();
  164. }
  165. if (configure.getValue('remove_short_link', true)) {
  166. window.addEventListener('DOMContentLoaded', this.removeShortLink);
  167. }
  168. if (configure.getValue('quick_by_pass_link', true)) {
  169. this.quickByPassLink();
  170. }
  171. }
  172. };
  173. //Logger Class
  174. var Logger = {
  175. style: 'color: #00DC58',
  176. info: function(text) {
  177. console.info('%cABPVN.COM Info: ', this.style, text);
  178. },
  179. warn: function(text) {
  180. console.warn('%cABPVN Warn: ', this.style, text);
  181. },
  182. error: function(text) {
  183. console.error('%cABPVN Error: ', this.style, text);
  184. },
  185. log: function(text) {
  186. console.log('%cABPVN Log: ', this.style, text);
  187. },
  188. };
  189. //get Link class
  190. var getLink = {
  191. settingKey: 'fshare_download',
  192. FShareConfig: function() {
  193. if (this.url.startWith('https://www.fshare.vn')) {
  194. var currentSetting = configure.getValue(this.settingKey, true);
  195. var background_image = !currentSetting ? 'url("http://i.imgur.com/kJnOMOB.png")' : 'url("http://i.imgur.com/2b7fN6a.png")';
  196. var title = currentSetting ? 'Bật get link fshare' : 'Tắt get link fshare';
  197. 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>';
  198. $(document).ready(function() {
  199. $(document.body).append(html);
  200. $(document).on('click', '#fs_click', function FS_on_off() {
  201. if (currentSetting) {
  202. currentSetting = false;
  203. this.style.backgroundImage = 'url("http://i.imgur.com/kJnOMOB.png")';
  204. this.setAttribute('title', 'Bật get link fshare');
  205. alert('Đã tắt get link fshare');
  206. } else {
  207. currentSetting = true;
  208. this.setAttribute('title', 'Tắt get link fshare');
  209. this.style.backgroundImage = 'url("http://i.imgur.com/2b7fN6a.png")';
  210. alert('Đã bật get link fshare');
  211. }
  212. configure.setValue("fshare_download", currentSetting);
  213. });
  214. });
  215. }
  216. },
  217. FShareGetLink: function() {
  218. if (this.url.startWith('https://www.fshare.vn/file/') && !this.url.startWith('https://www.fshare.vn/file/manager')) {
  219. var currentSetting = configure.getValue(this.settingKey, true);
  220. if (currentSetting) {
  221. console.info('Start get link Fshare.vn');
  222. $(document).ready(function() {
  223. var checkpassword = document.querySelector('.password-form');
  224. var linkcode = $('#linkcode').val();
  225. if (checkpassword === null) {
  226. var code = $('#form-download input[name="_csrf-app"]').val();
  227. var data = {
  228. '_csrf-app': code,
  229. 'fcode5': '',
  230. 'linkcode': linkcode,
  231. 'withFcode5': 0,
  232. };
  233. $.post('/download/get', data).done(function(data, statusText, xhr) {
  234. if (data.url === undefined) location.reload();
  235. else {
  236. if (typeof location != 'undefined') {
  237. Logger.log(location.href + ' -> ' + data.url);
  238. location.href = data.url;
  239. } else {
  240. $('.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>');
  241. }
  242. }
  243. }).fail(function(xhr, statusText, error) {
  244. alert('ABPVN: Đã có lỗi fshare hoặc file có password');
  245. });
  246. } else {
  247. alert('ABPVN: Hãy nhập mật khẩu cho file trước');
  248. }
  249. });
  250. } else {
  251. $('.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>');
  252. $('.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://vnlinks.net?link=' + location.href + '">Tải nhanh<span>Qua dịch vụ vnlinks.net</span></a>');
  253. }
  254. }
  255. },
  256. mediafire_com: function() {
  257. if (this.url.startWith('http://www.mediafire.com/file/') || this.url.startWith('https://www.mediafire.com/file/')) {
  258. var a_tag = document.querySelector('.download_link a.input');
  259. var link = a_tag.getAttribute('href');
  260. if (link.startWith('http')) {
  261. document.body.innerHTML = '<center><h1>ABPVN MediaFire Download đã hoạt động</h1><a href=\'http://abpvn.com/napthe\'><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>';
  262. location.href = link;
  263. }
  264. }
  265. },
  266. usercloud_com: function() {
  267. if (this.url.startWith('https://userscloud.com/') && this.url.length > 24) {
  268. var form = document.querySelector('form[name="F1"]');
  269. if (form) {
  270. form.submit();
  271. document.body.innerHTML = '<center><h1>ABPVN UserCloud Download đã hoạt động</h1><a href=\'http://abpvn.com/napthe\'><h1>Ủng hộ ABPVN</h1></center>';
  272. } else {
  273. var a_link = document.querySelector('h4 a.btn-success');
  274. if (a_link) {
  275. var link = a_link.getAttribute('href');
  276. if (link.startWith('https')) {
  277. location.href = link;
  278. document.body.innerHTML = '<center><h1>ABPVN UserCloud Download đã hoạt động</h1><a href=\'http://abpvn.com/napthe\'><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>';
  279. }
  280. }
  281. }
  282. }
  283. },
  284. init: function() {
  285. this.url = location.href;
  286. this.FShareConfig();
  287. this.FShareGetLink();
  288. if (configure.getValue('quick_download', true)) {
  289. this.mediafire_com();
  290. this.usercloud_com();
  291. }
  292. }
  293. };
  294. //Fix site class
  295. var fixSite = {
  296. elementExist: function(selector) {
  297. var check = document.querySelector(selector);
  298. return check != null;
  299. },
  300. getAllText: function(selector) {
  301. var text = '';
  302. var nodeList = document.querySelectorAll(selector);
  303. if (nodeList) {
  304. for (var i in nodeList) {
  305. if (nodeList[i].innerText) text += nodeList[i].innerText;
  306. }
  307. }
  308. return text;
  309. },
  310. getScript: function(url) {
  311. var xhr = new XMLHttpRequest();
  312. xhr.open('GET', url);
  313. xhr.addEventListener('load', function(data) {
  314. var blob = new Blob([xhr.responseText], {
  315. type: 'text/javascript'
  316. });
  317. var url = URL.createObjectURL(blob);
  318. var script = document.createElement('script');
  319. script.src = url;
  320. script.type = 'text/javascript';
  321. document.getElementsByTagName('head')[0].appendChild(script);
  322. });
  323. xhr.send();
  324. },
  325. loadCss: function(url, id) {
  326. var css_tag = document.createElement('link');
  327. css_tag.rel = 'stylesheet';
  328. css_tag.id = id;
  329. css_tag.href = url;
  330. var head = document.getElementsByTagName('head')[0];
  331. head.appendChild(css_tag);
  332. },
  333. phimmedia_tv: function() {
  334. if (this.url.startWith('https://www.phimmedia.tv/') || this.url.startWith('http://www.phimmedia.tv/')) {
  335. var links = document.querySelectorAll('#btn-film-watch,.poster > a');
  336. if (links) {
  337. for (var i = 0; i < links.length; i++) {
  338. var href = links[i].getAttribute('href');
  339. href = href.match('utm_id=.*')[0].replace('utm_id=', '');
  340. if (href) {
  341. links[i].setAttribute('href', atob(href));
  342. }
  343. }
  344. ABPVN.cTitle();
  345. }
  346. }
  347. },
  348. linkneverdie_com: function() {
  349. if (this.url.startWith('https://linkneverdie.com/')) {
  350. ABPVN.cTitle();
  351. var el = document.getElementById('wrapper');
  352. if (el) {
  353. el.id = "wrapper-fix-by-abpvn";
  354. }
  355. //Hide ads image
  356. var aTag = document.querySelector('#adsqca');
  357. if (aTag) {
  358. aTag.setAttribute('style', 'display:none !important');
  359. }
  360. }
  361. },
  362. hdonline_vn: function() {
  363. if (this.url.startWith('http://hdonline.vn')) {
  364. var links = document.querySelectorAll('a[href^="http://hub.blueserving.com/"]');
  365. for (var i in links) {
  366. var link = links[i];
  367. var href = link.getAttribute('href');
  368. href = href.match('url=.*')[0].replace('url=', '');
  369. if (href) {
  370. link.setAttribute('href', href);
  371. }
  372. }
  373. ABPVN.cTitle();
  374. }
  375. },
  376. maclife_vn: function() {
  377. if (this.url.startWith('https://maclife.vn/')) {
  378. var allShortUrl = document.querySelectorAll('a[rel]');
  379. var count = 0;
  380. for (var i = 0; i < allShortUrl.length; i++) {
  381. if (allShortUrl[i].innerText.indexOf('http') === 0) {
  382. allShortUrl[i].setAttribute('href', allShortUrl[i].innerText);
  383. count++;
  384. }
  385. }
  386. Logger.info("Đã xóa " + count + " link rút gọn!");
  387. }
  388. },
  389. aphim_co: function() {
  390. if (this.url.startWith('https://aphim.co/xem-phim/')) {
  391. ABPVN.cTitle();
  392. var aTagAds = document.querySelector('#video > a');
  393. aTagAds.setAttribute('href', '#abpvn');
  394. aTagAds.removeAttribute('target');
  395. Logger.info('Đã xóa link quảng cáo!');
  396. }
  397. },
  398. openload: function() {
  399. if (this.url.match(/^(https?:)?\/\/openload\.co\/*.*/) || this.url.match(/^(https?:)?\/\/oload\.\/*.*/)) {
  400. //Base on https://greasyfork.org/vi/scripts/17665-openload
  401. //
  402. // @run-at document-start
  403. //
  404. window.adblock = false;
  405. window.adblock2 = false;
  406. window.turnoff = true;
  407. window.open = function() {};
  408. //
  409. // @run-at document-end
  410. //
  411. function onready(fn) {
  412. if (document.readyState != 'loading') fn();
  413. else document.addEventListener('DOMContentLoaded', fn);
  414. }
  415. onready(function() {
  416. if (document.location.href.match(/\/embed\//) || $('#realdl>a')) {
  417. var streamurl = '#streamurl,#streamuri,#streamurj,#adbdetect + script + div > p:nth-child(2)';
  418. $('#btnView').hide();
  419. $('#btnDl').hide();
  420. $('.dlButtonContainer').show();
  421. $('h3.dlfile.h-method').hide();
  422. $('.col-md-4.col-centered-sm *').remove();
  423. $('#mgiframe,#main>div[id*="Composite"]').remove();
  424. $('#downloadTimer').hide();
  425. $('#mediaspace_wrapper').prepend($('<div/>').attr('id', 'realdl')
  426. .attr('style', 'position: absolute; top: 0 ; left: 0 ; right: 0; text-align: center; z-index: 9999; background-color: #00DC58; padding: .5em 0;')
  427. .on('mouseenter', function() {
  428. $(this).fadeTo(500, 1);
  429. }).on('mouseleave', function() {
  430. $(this).fadeTo(500, 0);
  431. })
  432. .append($('<a/>').attr('href', '').attr('style', 'color: #fff; text-decoration: none;').html('FREE DOWNLOAD<sub>Power by abpvn.com</sub>')));
  433. if (document.location.href.match(/\/embed\//)) {
  434. setTimeout(function() {
  435. $('#realdl').fadeTo(500, 0);
  436. }, 1500);
  437. }
  438. $('#realdl').show();
  439. var streamurl_tmr = setInterval(function() {
  440. // <@snippet author="https://greasyfork.org/forum/profile/daedelus" src="https://greasyfork.org/forum/discussion/36362/x">
  441. var streamurl_src;
  442. $('p[id]').each(function() {
  443. streamurl_src = streamurl_src || ($(this).text().match(/^[\w\.~-]+$/) && $(this).text().match(/~/)) ? $(this).text() : streamurl_src;
  444. });
  445. // </@snippet>
  446. if (streamurl_src) {
  447. var streamurl_url = location.origin + '/stream/' + streamurl_src;
  448. $('#realdl a').attr('href', streamurl_url);
  449. $('#steamcopy').text(streamurl_url);
  450. $('#videooverlay').click();
  451. clearInterval(streamurl_tmr);
  452. }
  453. }, 100);
  454. }
  455. window.onclick = function() {};
  456. document.onclick = function() {};
  457. document.body.onclick = function() {};
  458. });
  459. }
  460. },
  461. fontdep_com: function() {
  462. if (this.url.startWith('http://www.fontdep.com/') && document.cookie.indexOf('virallock_myid') == -1) {
  463. document.cookie = 'virallock_myid=0001';
  464. location.reload();
  465. }
  466. },
  467. antiAdblockRemover: function() {
  468. var msg = 'By pass adBlock detect rồi nhé! Hahahahaha 😁😁😁';
  469. if (typeof adBlockDetected === 'function') {
  470. adBlockDetected = function() {
  471. Logger.info(msg);
  472. };
  473. }
  474. if (typeof showAdsBlock === 'function') {
  475. showAdsBlock = function() {
  476. Logger.info(msg);
  477. };
  478. }
  479. },
  480. removeRedir: function(config) {
  481. if (this.url.match(new RegExp(config.url, 'g')) || this.url.startWith(config.url)) {
  482. ABPVN.cTitle();
  483. var links = document.querySelectorAll(config.selector || 'a[href^="' + config.replace + '"]');
  484. Logger.info('Remove Redirect for ' + links.length + ' links');
  485. if (links.length) {
  486. links.forEach(function(item) {
  487. var stockUrl = item.getAttribute('href').replace(config.replace, '');
  488. var count = 0;
  489. while (stockUrl.indexOf('%2') > -1 && count < 5) {
  490. stockUrl = decodeURIComponent(stockUrl);
  491. count++;
  492. }
  493. item.setAttribute('href', stockUrl);
  494. item.setAttribute('title', 'Link đã xóa chuyển hướng trung gian bởi abpvn.com');
  495. }.bind(this));
  496. }
  497. }
  498. },
  499. removeRedirect() {
  500. var configs = [{
  501. url: 'https://samsungvn.com',
  502. replace: 'https://samsungvn.com/xfa-interstitial/redirect?url=',
  503. },
  504. {
  505. url: 'https://forum.vietdesigner.net',
  506. replace: 'redirect/?url='
  507. },
  508. {
  509. url: 'http://sinhvienit.net',
  510. replace: 'http://sinhvienit.net/goto/?'
  511. },
  512. {
  513. url: 'http://phanmemaz.com/',
  514. replace: 'http://phanmemaz.com/wp-content/plugins/tm-wordpress-redirection/l.php?'
  515. },
  516. {
  517. url: 'forums.voz.vn/showthread.php',
  518. replace: '/redirect/index.php?link='
  519. },
  520. {
  521. url: 'www.webtretho.com/forum/',
  522. replace: /http(s?):\/\/webtretho\.com\/forum\/links\.php\?url=/,
  523. selector: 'a[href*="webtretho.com/forum/links.php?url="]'
  524. }
  525. ];
  526. configs.forEach(function(config) {
  527. this.removeRedir(config);
  528. }.bind(this));
  529. },
  530. init: function() {
  531. this.url = location.href;
  532. if (configure.getValue('remove_redirect', true)) {
  533. this.removeRedirect();
  534. }
  535. this.antiAdblockRemover();
  536. this.phimmedia_tv();
  537. this.linkneverdie_com();
  538. this.hdonline_vn();
  539. this.maclife_vn();
  540. this.aphim_co();
  541. this.fontdep_com();
  542. this.openload();
  543. }
  544. };
  545. //Ad blocker script
  546. var adBlocker = {
  547. blockPopUp: function() {
  548. var listSite = [
  549. 'blogtruyen.com',
  550. 'www.khosachnoi.net',
  551. 'hamtruyen.vn',
  552. 'phim14.net',
  553. 'phim7.com',
  554. 'www.diendan.trentroiduoidat.com',
  555. 'www.trentroiduoidat.com',
  556. 'chophanthiet.us',
  557. 'animetvn.com',
  558. 'font.vn',
  559. 'vidoza.net',
  560. 'www.easysoft.xyz',
  561. 'hdonline.vn',
  562. 'www.phim.media',
  563. 'phimnhanh.com',
  564. 'www.vietsubhd.com',
  565. 'www.phimmedia.tv',
  566. 'tvhay.org',
  567. 'bilutv.org'
  568. ];
  569. for (var i = 0; i < listSite.length; i++) {
  570. if (location.hostname === listSite[i]) {
  571. ABPVN.cTitle();
  572. Logger.info('Đã chặn popup quảng cáo');
  573. document.body.onclick = null;
  574. document.onclick = null;
  575. document.ontouchstart = null;
  576. document.onmousedown = null;
  577. window.addEventListener('load', function() {
  578. setTimeout(function() {
  579. Logger.info('Đã chặn popup quảng cáo onload');
  580. document.ontouchstart = null;
  581. document.onclick = null;
  582. document.body.onclick = null;
  583. document.onmousedown = null;
  584. }, 300);
  585. });
  586. window.addEventListener('DOMContentLoaded', function() {
  587. setTimeout(function() {
  588. Logger.info('Đã chặn popup quảng cáo dom load');
  589. document.ontouchstart = null;
  590. document.onclick = null;
  591. document.body.onclick = null;
  592. document.onmousedown = null;
  593. }, 300);
  594. });
  595. }
  596. }
  597. },
  598. mgIdAdRemover: function() {
  599. var allMgIdEl = document.querySelectorAll('[id*="ScriptRoot"]');
  600. if (allMgIdEl && allMgIdEl.length) {
  601. ABPVN.cTitle();
  602. for (var i = 0; i < allMgIdEl.length; i++) {
  603. allMgIdEl[i].id = 'ScriptRoot-removed-by-abpvn-' + Math.random();
  604. allMgIdEl[i].innerHTML = '';
  605. }
  606. }
  607. },
  608. phimnhanh_com: function() {
  609. if (this.url.startWith('http://phimnhanh.com/xem-phim')) {
  610. Logger.warn('Đã chặn video preload');
  611. if (video !== undefined) {
  612. video.preroll = function(options) {};
  613. }
  614. }
  615. },
  616. init: function() {
  617. this.url = location.href;
  618. this.mgIdAdRemover();
  619. this.blockPopUp();
  620. this.phimnhanh_com();
  621. },
  622. };
  623. var configure = {
  624. urls: {
  625. setting: 'https://abpvn.com/script-setting.html',
  626. issue: 'https://github.com/abpvn/abpvn/issues/new',
  627. fanpage: 'https://www.facebook.com/abpvn.org',
  628. },
  629. openUrl: function(url) {
  630. if (typeof GM_openInTab === 'function') {
  631. GM_openInTab(url);
  632. }
  633. },
  634. getValue: function(key, defaultValue) {
  635. var value;
  636. if (typeof GM_getValue === 'function') {
  637. value = GM_getValue(key);
  638. }
  639. if (typeof value === 'undefined') {
  640. return defaultValue;
  641. }
  642. return value;
  643. },
  644. setValue: function(key, value) {
  645. if (typeof GM_setValue === 'function') {
  646. return GM_setValue(key, value);
  647. }
  648. },
  649. setUpSetting: function() {
  650. if (this.url === this.urls.setting) {
  651. var settingContainer = document.querySelector('#setting-container');
  652. if (settingContainer) {
  653. settingContainer.classList.add('installed');
  654. var allSetting = settingContainer.querySelectorAll('input[type="checkbox"]');
  655. if (allSetting) {
  656. allSetting.forEach(checkbox => {
  657. checkbox.checked = this.getValue(checkbox.name, true);
  658. checkbox.addEventListener('change', event => {
  659. var target = event.target;
  660. var key = target.name;
  661. this.setValue(key, event.target.checked);
  662. });
  663. });
  664. }
  665. }
  666. }
  667. },
  668. init: function() {
  669. this.url = location.href;
  670. if (typeof GM_registerMenuCommand === 'function') {
  671. GM_registerMenuCommand('ABPVN - Cài đặt', () => {
  672. this.openUrl(this.urls.setting);
  673. });
  674. GM_registerMenuCommand('ABPVN - Báo lỗi', () => {
  675. this.openUrl(this.urls.issue);
  676. });
  677. GM_registerMenuCommand('ABPVN - Fanpage', () => {
  678. this.openUrl(this.urls.fanpage);
  679. });
  680. }
  681. this.setUpSetting();
  682. }
  683. };
  684. //Main class
  685. var ABPVN = {
  686. cTitle: function() {
  687. if (document.title.indexOf(' - Fixed by ABPVN.COM') === -1) {
  688. document.title = document.title + ' - Fixed by ABPVN.COM';
  689. }
  690. },
  691. init: function() {
  692. //Init class adBlocker
  693. adBlocker.init();
  694. //Init class getLink
  695. getLink.init();
  696. //Init class Fixsite
  697. fixSite.init();
  698. //Init bypass class
  699. byPass.init();
  700. if (window === window.parent) {
  701. //Init Congfiure
  702. configure.init();
  703. }
  704. }
  705. };
  706. //RUN INNIT
  707. ABPVN.init();