Greasy Fork is available in English.

ABPVN AdsBlock

Script block ads, remove wating of ABPVN

As of 15.02.2023. See ბოლო ვერსია.

  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.22
  19. // @change-log Add saostar.vn css placeholder fix
  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. saostar_vn: function() {
  355. if (this.url.startWith('https://www.saostar.vn/')) {
  356. const styleTag = document.createElement('style');
  357. styleTag.innerHTML = 'header.bg-white {margin-top: 0 !important}.layout.pt-mobi-top {padding-top: 0 !important}';
  358. document.head.appendChild(styleTag);
  359. ABPVN.cTitle();
  360. }
  361. },
  362. removeRedir: function(config) {
  363. if (this.url.match(new RegExp(config.url, 'g')) || this.url.startWith(config.url)) {
  364. ABPVN.cTitle();
  365. var links = document.querySelectorAll(config.selector || 'a[href^="' + config.replace + '"]');
  366. Logger.info('Remove Redirect for ' + links.length + ' links');
  367. if (links.length) {
  368. links.forEach(function(item) {
  369. var stockUrl = item.getAttribute('href').replace(config.replace, '');
  370. var count = 0;
  371. while (stockUrl.indexOf('%2') > -1 && count < 5) {
  372. stockUrl = decodeURIComponent(stockUrl);
  373. count++;
  374. }
  375. count = 0;
  376. while (stockUrl.indexOf('aHR0c') === 0 && count < 5) {
  377. stockUrl = atob(stockUrl);
  378. count++;
  379. }
  380. item.setAttribute('href', stockUrl);
  381. item.setAttribute('title', 'Link đã xóa chuyển hướng trung gian bởi abpvn.com');
  382. }.bind(this));
  383. }
  384. }
  385. },
  386. removeRedirect() {
  387. var configs = [
  388. {
  389. url: 'https://samsungvn.com',
  390. replace: 'https://samsungvn.com/xfa-interstitial/redirect?url=',
  391. },
  392. {
  393. url: 'https://forum.vietdesigner.net',
  394. replace: 'redirect/?url='
  395. },
  396. {
  397. url: 'www.webtretho.com/forum/',
  398. replace: /http(s?):\/\/webtretho\.com\/forum\/links\.php\?url=/,
  399. selector: 'a[href*="webtretho.com/forum/links.php?url="]'
  400. },
  401. {
  402. url: 'https://tuong.me/',
  403. replace: 'https://tuong.me/chuyen-huong/?url='
  404. },
  405. {
  406. url: 'https://yhocdata.com/',
  407. replace: 'https://yhocdata.com/redirect/?url='
  408. },
  409. {
  410. url: 'https://vn-z.vn/',
  411. replace: 'https://vn-z.vn/redirect?to='
  412. },
  413. {
  414. url: 'https://romgoc.net',
  415. replace: 'https://romgoc.net/redirect-to/?url='
  416. },
  417. {
  418. url: 'https://tophanmem.com',
  419. replace: 'https://tophanmem.com/redirect-to/?url='
  420. },
  421. {
  422. url: 'https://anonyviet.com',
  423. replace: 'https://anonyviet.com/tieptucdidentrangmoi/?url='
  424. },
  425. {
  426. url: 'https://icongnghe.com',
  427. replace: 'https://icongnghe.com/download/?url='
  428. },
  429. {
  430. url: 'https://cakhia-tv.onl',
  431. replace: '/chuyen-huong/?redirect='
  432. }
  433. ];
  434. configs.forEach(function(config) {
  435. this.removeRedir(config);
  436. }.bind(this));
  437. },
  438. init: function() {
  439. this.url = location.href;
  440. if (configure.getValue('remove_redirect', true)) {
  441. this.removeRedirect();
  442. }
  443. this.antiAdblockRemover();
  444. this.topphimhd_info();
  445. this.luotphim();
  446. this.ios_codevn_net();
  447. this.saostar_vn();
  448. }
  449. };
  450. //Ad blocker script
  451. var adBlocker = {
  452. mgIdAdRemover: function() {
  453. const skipDomain = /ios.codevn.net/;
  454. if (skipDomain.test(location.hostname)) {
  455. return;
  456. }
  457. var allMgIdEl = document.querySelectorAll('[id*="ScriptRoot"]');
  458. if (allMgIdEl && allMgIdEl.length) {
  459. ABPVN.cTitle();
  460. Logger.log('Removed mgIdAd placeholder');
  461. for (var i = 0; i < allMgIdEl.length; i++) {
  462. if (location.hostname !== 'megaup.net') {
  463. allMgIdEl[i].id = 'ScriptRoot-removed-by-abpvn-' + Math.random();
  464. }
  465. allMgIdEl[i].innerHTML = '';
  466. }
  467. }
  468. },
  469. noAdsModal: function() {
  470. const domainRegex = /vebo|90phut|khomuc|xoilac|banhkhuc/;
  471. if (location.hostname.match(domainRegex)) {
  472. const styleTag = document.createElement('style');
  473. styleTag.innerHTML = 'html,body{overflow: auto!important} .modal-backdrop,.modal{display: none!important}';
  474. document.head.appendChild(styleTag);
  475. ABPVN.cTitle();
  476. }
  477. },
  478. init: function() {
  479. this.url = location.href;
  480. this.mgIdAdRemover();
  481. this.noAdsModal();
  482. },
  483. };
  484. var configure = {
  485. urls: {
  486. setting: 'https://abpvn.com/script-setting.html',
  487. issue: 'https://github.com/abpvn/abpvn/issues/new',
  488. fanpage: 'https://www.facebook.com/abpvn.org',
  489. },
  490. openUrl: function(url) {
  491. if (typeof GM_openInTab === 'function') {
  492. GM_openInTab(url);
  493. }
  494. },
  495. getValue: function(key, defaultValue) {
  496. var value;
  497. if (typeof GM_getValue === 'function') {
  498. value = GM_getValue(key);
  499. }
  500. if (typeof value === 'undefined') {
  501. return defaultValue;
  502. }
  503. return value;
  504. },
  505. setValue: function(key, value) {
  506. if (typeof GM_setValue === 'function') {
  507. return GM_setValue(key, value);
  508. }
  509. },
  510. setUpSetting: function() {
  511. if (this.url === this.urls.setting) {
  512. var settingContainer = document.querySelector('#setting-container');
  513. if (settingContainer) {
  514. settingContainer.classList.add('installed');
  515. var allSetting = settingContainer.querySelectorAll('input[type="checkbox"]');
  516. if (allSetting) {
  517. allSetting.forEach(checkbox => {
  518. checkbox.checked = this.getValue(checkbox.name, true);
  519. checkbox.addEventListener('change', event => {
  520. var target = event.target;
  521. var key = target.name;
  522. this.setValue(key, event.target.checked);
  523. });
  524. });
  525. }
  526. }
  527. }
  528. },
  529. init: function() {
  530. this.url = location.href;
  531. if (typeof GM_registerMenuCommand === 'function') {
  532. GM_registerMenuCommand('ABPVN - Cài đặt', () => {
  533. this.openUrl(this.urls.setting);
  534. });
  535. GM_registerMenuCommand('ABPVN - Báo lỗi', () => {
  536. this.openUrl(this.urls.issue);
  537. });
  538. GM_registerMenuCommand('ABPVN - Fanpage', () => {
  539. this.openUrl(this.urls.fanpage);
  540. });
  541. }
  542. this.setUpSetting();
  543. }
  544. };
  545. //Main class
  546. var ABPVN = {
  547. cTitle: function() {
  548. if (document.title.indexOf(' - Fixed by ABPVN.COM') === -1) {
  549. document.title = document.title + ' - Fixed by ABPVN.COM';
  550. }
  551. },
  552. init: function() {
  553. //Init class adBlocker
  554. adBlocker.init();
  555. //Init class getLink
  556. getLink.init();
  557. //Init class Fixsite
  558. fixSite.init();
  559. //Init bypass class
  560. byPass.init();
  561. if (window === window.parent) {
  562. //Init Congfiure
  563. configure.init();
  564. }
  565. }
  566. };
  567. //RUN INNIT
  568. ABPVN.init();