ABPVN AdsBlock

Script block ads, remove wating of ABPVN

Version vom 02.12.2022. Aktuellste Version

  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.3.18
  19. // @change-log Add khomuc modal ads blocker
  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. showBodyLinkByPassAndRedirect: function(link) {
  82. document.body.innerHTML = '<style>html,body{background: #fff !important;}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>';
  83. setTimeout(() => location.href = link, 500);
  84. },
  85. quickByPassLink: function() {
  86. var regex = /123link\..*|phlame.pw|megaurl\.*|www.123l\.*|vinaurl\.*|share4you.pro|doxeaz10.site|derow.win|linkviet.net|ez4linkss.com|ckk.ai|link.codevn.net|linksht.com|beta.shortearn.eu|getlink.tienichmaytinh.net|download.baominh.tech|download3s.net/;
  87. var largeTimeoutHost = /share4you.pro|derow.win/;
  88. var autoCaptchaOnlyList = /megaurl\.*|vinaurl\.*|doxeaz10.site|linkviet.net|ez4linkss.com|ckk.ai|link.codevn.net|beta.shortearn.eu|getlink.tienichmaytinh.net|download.baominh.tech|download3s.net/;
  89. if (regex.test(location.hostname)) {
  90. try {
  91. var checkClick = function(mutation) {
  92. if (mutation.attributeName === "disabled" && !mutation.target.disabled) {
  93. return true;
  94. }
  95. if (mutation.attributeName === "class" && !mutation.target.classList.contains('disabled')) {
  96. return true;
  97. }
  98. return false;
  99. }
  100. var link;
  101. // Set up a new observer
  102. var observer = new MutationObserver((mutations) => {
  103. mutations.forEach((mutation) => {
  104. // Check the modified attributeName is "disabled"
  105. if (checkClick(mutation)) {
  106. mutation.target.click();
  107. }
  108. if (mutation.attributeName === "href") {
  109. link = mutation.target.getAttribute("href");
  110. this.showBodyLinkByPassAndRedirect(link);
  111. }
  112. });
  113. });
  114. // Configure to only listen to attribute changes
  115. var config = {
  116. attributes: true
  117. };
  118. var button = document.getElementById('invisibleCaptchaShortlink') || document.querySelector('.download_1');
  119. if (button) {
  120. observer.observe(button, config);
  121. } else if (document.querySelector('#originalLink')) {
  122. link = document.querySelector('#originalLink').getAttribute("href");
  123. this.showBodyLinkByPassAndRedirect(link);
  124. } else {
  125. var getLinkl = document.querySelector('.get-link');
  126. var timeout = largeTimeoutHost.test(location.hostname) ? 6000 : 100;
  127. if (getLinkl) {
  128. observer.observe(getLinkl, config);
  129. if (!autoCaptchaOnlyList.test(location.hostname)) {
  130. setTimeout(function() {
  131. $("#go-link").addClass("go-link").trigger("submit.adLinkFly.counterSubmit").one("submit.adLinkFly.counterSubmit", function(e) {
  132. e.preventDefault();
  133. if (!largeTimeoutHost.test(location.hostname)) {
  134. location.reload();
  135. }
  136. });
  137. }, timeout);
  138. }
  139. }
  140. }
  141. } catch (e) {
  142. Logger.error(e);
  143. }
  144. }
  145. },
  146. wikiall_org: function() {
  147. if (location.hostname == 'wikiall.org' && document.querySelector('#timer')) {
  148. var observer = new MutationObserver((mutations) => {
  149. mutations.forEach((mutation) => {
  150. // Check the modified childList of place
  151. if (mutation.type == 'childList') {
  152. var targetA = mutation.target.querySelector('a');
  153. this.showBodyLinkByPassAndRedirect(targetA.getAttribute('href'));
  154. }
  155. });
  156. });
  157. // Configure to only listen to attribute changes
  158. var place = document.querySelector('#place');
  159. observer.observe(place, {
  160. childList: true
  161. });
  162. }
  163. },
  164. link1s_com: function() {
  165. window.addEventListener("DOMContentLoaded", () => {
  166. // step 1
  167. let link1sgo = document.querySelector('a#link1s');
  168. if (link1sgo && link1sgo.getAttribute('href').match(/http?s:\/\//)) {
  169. Logger.info('Link1s.com step 1 match');
  170. let link = link1sgo.getAttribute('href');
  171. this.showBodyLinkByPassAndRedirect(link);
  172. return;
  173. }
  174. // step 2
  175. let btnGo = document.querySelector('#link1s-snp .btn-primary');
  176. if (btnGo) {
  177. Logger.info('Link1s.com step 2 match');
  178. Logger.info('Finding next url');
  179. let allScriptText = [...document.querySelectorAll('script')].map(el => el.innerText).join("\n");
  180. let nextUrlMatch = allScriptText.match(/link1sLink\s=\s\'(.+)\';/);
  181. if (nextUrlMatch && nextUrlMatch[1]) {
  182. this.showBodyLinkByPassAndRedirect(nextUrlMatch[1]);
  183. return;
  184. }
  185. }
  186. // step 3
  187. var observer = new MutationObserver((mutations) => {
  188. mutations.forEach((mutation) => {
  189. // Check the modified attributeName is "disabled"
  190. if (mutation.attributeName === "href") {
  191. link = mutation.target.getAttribute("href");
  192. this.showBodyLinkByPassAndRedirect(link);
  193. }
  194. });
  195. });
  196. var config = {
  197. attributes: true,
  198. subtree: true
  199. };
  200. if (location.hostname === 'link1s.com' && (document.querySelector('.get-link') || document.querySelector('.skip-ad'))) {
  201. Logger.info('Link1s.com step 3 match');
  202. observer.observe((document.querySelector('.get-link') || document.querySelector('.skip-ad')), config);
  203. }
  204. });
  205. },
  206. init: function() {
  207. if (configure.getValue('unlock_content', true)) {
  208. window.addEventListener('DOMContentLoaded', this.hideLinkUnlock);
  209. window.addEventListener('load', this.hideLinkUnlock);
  210. this.hideLinkUnlock();
  211. }
  212. if (configure.getValue('remove_short_link', true)) {
  213. window.addEventListener('DOMContentLoaded', this.removeShortLink);
  214. }
  215. if (configure.getValue('quick_by_pass_link', true)) {
  216. this.quickByPassLink();
  217. this.wikiall_org();
  218. this.link1s_com();
  219. }
  220. }
  221. };
  222. //Logger Class
  223. var Logger = {
  224. style: 'color: #00DC58',
  225. info: function(text) {
  226. console.info('%cABPVN.COM Info: ', this.style, text);
  227. },
  228. warn: function(text) {
  229. console.warn('%cABPVN Warn: ', this.style, text);
  230. },
  231. error: function(text) {
  232. console.error('%cABPVN Error: ', this.style, text);
  233. },
  234. log: function(text) {
  235. console.log('%cABPVN Log: ', this.style, text);
  236. },
  237. };
  238. //get Link class
  239. var getLink = {
  240. showBodyLinkDownloadAndRedirect: function(label, link) {
  241. document.body.innerHTML = '<style>html,body{background: #fff !important;}h1{color: #00dc58;}a{color: #015199}a h1{color: #015199;}</style><center><h1>ABPVN ' + label + ' 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>';
  242. location.href = link;
  243. },
  244. mediafire_com: function() {
  245. if (this.url.startWith('http://www.mediafire.com/file/') || this.url.startWith('https://www.mediafire.com/file/')) {
  246. var a_tag = document.querySelector('.download_link a.input');
  247. var link = a_tag.getAttribute('href');
  248. if (link.startWith('http')) {
  249. this.showBodyLinkDownloadAndRedirect('MediaFire', link);
  250. }
  251. }
  252. },
  253. init: function() {
  254. this.url = location.href;
  255. if (configure.getValue('quick_download', true)) {
  256. this.mediafire_com();
  257. }
  258. }
  259. };
  260. //Fix site class
  261. var fixSite = {
  262. elementExist: function(selector) {
  263. var check = document.querySelector(selector);
  264. return check != null;
  265. },
  266. getAllText: function(selector) {
  267. var text = '';
  268. var nodeList = document.querySelectorAll(selector);
  269. if (nodeList) {
  270. for (var i in nodeList) {
  271. if (nodeList[i].innerText) text += nodeList[i].innerText;
  272. }
  273. }
  274. return text;
  275. },
  276. getScript: function(url) {
  277. var xhr = new XMLHttpRequest();
  278. xhr.open('GET', url);
  279. xhr.addEventListener('load', function(data) {
  280. var blob = new Blob([xhr.responseText], {
  281. type: 'text/javascript'
  282. });
  283. var blobUrl = URL.createObjectURL(blob);
  284. var script = document.createElement('script');
  285. script.src = blobUrl;
  286. script.type = 'text/javascript';
  287. document.getElementsByTagName('head')[0].appendChild(script);
  288. });
  289. xhr.send();
  290. },
  291. loadCss: function(url, id) {
  292. var css_tag = document.createElement('link');
  293. css_tag.rel = 'stylesheet';
  294. css_tag.id = id;
  295. css_tag.href = url;
  296. var head = document.getElementsByTagName('head')[0];
  297. head.appendChild(css_tag);
  298. },
  299. antiAdblockRemover: function() {
  300. try {
  301. var msg = 'By pass adBlock detect rồi nhé! Hahahahaha 😁😁😁';
  302. if (typeof adBlockDetected === 'function') {
  303. adBlockDetected = function() {
  304. Logger.info(msg);
  305. };
  306. }
  307. if (typeof showAdsBlock === 'function') {
  308. showAdsBlock = function() {
  309. Logger.info(msg);
  310. };
  311. }
  312. if (typeof nothingCanStopMeShowThisMessage === 'function') {
  313. nothingCanStopMeShowThisMessage = function() {
  314. Logger.info(msg);
  315. };
  316. }
  317. } catch (e) {
  318. Logger.error(e);
  319. }
  320. },
  321. topphimhd_info: function() {
  322. if (this.url.startWith('http://lb.topphimhd.info')) {
  323. var adSourceEl = document.querySelector('[data-ads=""]');
  324. if (adSourceEl) {
  325. adSourceEl.remove();
  326. Logger.log("Removed ads source");
  327. ABPVN.cTitle();
  328. }
  329. }
  330. },
  331. luotphim: function() {
  332. if (this.url.startWith('https://luotphim.top/xem-phim') || this.url.startWith('https://luotphim.top/phim-') || this.url.startWith("https://luotphim.fun/xem-phim") || this.url.startWith("https://luotphim.fun/phim-")) {
  333. var clickCount = 1;
  334. var interval = setInterval(() => {
  335. if (document.querySelector('.btn-close-preroll') && document.querySelector('#fakeplayer').style.display != 'none') {
  336. Logger.log("Click to by pass preroll: " + clickCount);
  337. clickCount++;
  338. document.querySelector('.btn-close-preroll').click();
  339. } else {
  340. clearInterval(interval);
  341. Logger.log("By passed preroll");
  342. }
  343. }, 100);
  344. }
  345. },
  346. ios_codevn_net: function () {
  347. if (this.url.match(/ios.codevn.net/)) {
  348. const styleTag = document.createElement('style');
  349. styleTag.innerHTML = 'div[id*="ScriptRoot"]{height: 1px !important;}';
  350. document.head.appendChild(styleTag);
  351. ABPVN.cTitle();
  352. }
  353. },
  354. removeRedir: function(config) {
  355. if (this.url.match(new RegExp(config.url, 'g')) || this.url.startWith(config.url)) {
  356. ABPVN.cTitle();
  357. var links = document.querySelectorAll(config.selector || 'a[href^="' + config.replace + '"]');
  358. Logger.info('Remove Redirect for ' + links.length + ' links');
  359. if (links.length) {
  360. links.forEach(function(item) {
  361. var stockUrl = item.getAttribute('href').replace(config.replace, '');
  362. var count = 0;
  363. while (stockUrl.indexOf('%2') > -1 && count < 5) {
  364. stockUrl = decodeURIComponent(stockUrl);
  365. count++;
  366. }
  367. count = 0;
  368. while (stockUrl.indexOf('aHR0c') === 0 && count < 5) {
  369. stockUrl = atob(stockUrl);
  370. count++;
  371. }
  372. item.setAttribute('href', stockUrl);
  373. item.setAttribute('title', 'Link đã xóa chuyển hướng trung gian bởi abpvn.com');
  374. }.bind(this));
  375. }
  376. }
  377. },
  378. removeRedirect() {
  379. var configs = [
  380. {
  381. url: 'https://samsungvn.com',
  382. replace: 'https://samsungvn.com/xfa-interstitial/redirect?url=',
  383. },
  384. {
  385. url: 'https://forum.vietdesigner.net',
  386. replace: 'redirect/?url='
  387. },
  388. {
  389. url: 'www.webtretho.com/forum/',
  390. replace: /http(s?):\/\/webtretho\.com\/forum\/links\.php\?url=/,
  391. selector: 'a[href*="webtretho.com/forum/links.php?url="]'
  392. },
  393. {
  394. url: 'https://tuong.me/',
  395. replace: 'https://tuong.me/chuyen-huong/?url='
  396. },
  397. {
  398. url: 'https://yhocdata.com/',
  399. replace: 'https://yhocdata.com/redirect/?url='
  400. },
  401. {
  402. url: 'https://vn-z.vn/',
  403. replace: 'https://vn-z.vn/redirect?to='
  404. },
  405. {
  406. url: 'https://romgoc.net',
  407. replace: 'https://romgoc.net/redirect-to/?url='
  408. },
  409. {
  410. url: 'https://tophanmem.com',
  411. replace: 'https://tophanmem.com/redirect-to/?url='
  412. },
  413. {
  414. url: 'https://anonyviet.com',
  415. replace: 'https://anonyviet.com/tieptucdidentrangmoi/?url='
  416. },
  417. {
  418. url: 'https://icongnghe.com',
  419. replace: 'https://icongnghe.com/download/?url='
  420. },
  421. {
  422. url: 'https://cakhia-tv.onl',
  423. replace: '/chuyen-huong/?redirect='
  424. }
  425. ];
  426. configs.forEach(function(config) {
  427. this.removeRedir(config);
  428. }.bind(this));
  429. },
  430. init: function() {
  431. this.url = location.href;
  432. if (configure.getValue('remove_redirect', true)) {
  433. this.removeRedirect();
  434. }
  435. this.antiAdblockRemover();
  436. this.topphimhd_info();
  437. this.luotphim();
  438. this.ios_codevn_net();
  439. }
  440. };
  441. //Ad blocker script
  442. var adBlocker = {
  443. mgIdAdRemover: function() {
  444. const skipDomain = /ios.codevn.net/;
  445. if (skipDomain.test(location.hostname)) {
  446. return;
  447. }
  448. var allMgIdEl = document.querySelectorAll('[id*="ScriptRoot"]');
  449. if (allMgIdEl && allMgIdEl.length) {
  450. ABPVN.cTitle();
  451. Logger.log('Removed mgIdAd placeholder');
  452. for (var i = 0; i < allMgIdEl.length; i++) {
  453. if (location.hostname !== 'megaup.net') {
  454. allMgIdEl[i].id = 'ScriptRoot-removed-by-abpvn-' + Math.random();
  455. }
  456. allMgIdEl[i].innerHTML = '';
  457. }
  458. }
  459. },
  460. noAdsModal: function() {
  461. const domainRegex = /vebotv.|90phut|khomuc/;
  462. if (location.hostname.match(domainRegex)) {
  463. const styleTag = document.createElement('style');
  464. styleTag.innerHTML = 'html,body{overflow: auto!important} .modal-backdrop,.modal{display: none!important}';
  465. document.head.appendChild(styleTag);
  466. ABPVN.cTitle();
  467. }
  468. },
  469. init: function() {
  470. this.url = location.href;
  471. this.mgIdAdRemover();
  472. this.noAdsModal();
  473. },
  474. };
  475. var configure = {
  476. urls: {
  477. setting: 'https://abpvn.com/script-setting.html',
  478. issue: 'https://github.com/abpvn/abpvn/issues/new',
  479. fanpage: 'https://www.facebook.com/abpvn.org',
  480. },
  481. openUrl: function(url) {
  482. if (typeof GM_openInTab === 'function') {
  483. GM_openInTab(url);
  484. }
  485. },
  486. getValue: function(key, defaultValue) {
  487. var value;
  488. if (typeof GM_getValue === 'function') {
  489. value = GM_getValue(key);
  490. }
  491. if (typeof value === 'undefined') {
  492. return defaultValue;
  493. }
  494. return value;
  495. },
  496. setValue: function(key, value) {
  497. if (typeof GM_setValue === 'function') {
  498. return GM_setValue(key, value);
  499. }
  500. },
  501. setUpSetting: function() {
  502. if (this.url === this.urls.setting) {
  503. var settingContainer = document.querySelector('#setting-container');
  504. if (settingContainer) {
  505. settingContainer.classList.add('installed');
  506. var allSetting = settingContainer.querySelectorAll('input[type="checkbox"]');
  507. if (allSetting) {
  508. allSetting.forEach(checkbox => {
  509. checkbox.checked = this.getValue(checkbox.name, true);
  510. checkbox.addEventListener('change', event => {
  511. var target = event.target;
  512. var key = target.name;
  513. this.setValue(key, event.target.checked);
  514. });
  515. });
  516. }
  517. }
  518. }
  519. },
  520. init: function() {
  521. this.url = location.href;
  522. if (typeof GM_registerMenuCommand === 'function') {
  523. GM_registerMenuCommand('ABPVN - Cài đặt', () => {
  524. this.openUrl(this.urls.setting);
  525. });
  526. GM_registerMenuCommand('ABPVN - Báo lỗi', () => {
  527. this.openUrl(this.urls.issue);
  528. });
  529. GM_registerMenuCommand('ABPVN - Fanpage', () => {
  530. this.openUrl(this.urls.fanpage);
  531. });
  532. }
  533. this.setUpSetting();
  534. }
  535. };
  536. //Main class
  537. var ABPVN = {
  538. cTitle: function() {
  539. if (document.title.indexOf(' - Fixed by ABPVN.COM') === -1) {
  540. document.title = document.title + ' - Fixed by ABPVN.COM';
  541. }
  542. },
  543. init: function() {
  544. //Init class adBlocker
  545. adBlocker.init();
  546. //Init class getLink
  547. getLink.init();
  548. //Init class Fixsite
  549. fixSite.init();
  550. //Init bypass class
  551. byPass.init();
  552. if (window === window.parent) {
  553. //Init Congfiure
  554. configure.init();
  555. }
  556. }
  557. };
  558. //RUN INNIT
  559. ABPVN.init();