ABPVN AdsBlock

Script block ads, remove wating of ABPVN

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