Greasy Fork is available in English.

ABPVN AdsBlock

Script chặn quảng cáo,loại bỏ chờ đợi của ABPVN

Fra 23.05.2018. Se den seneste versjonen.

  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 chặn quảng cáo,loại bỏ chờ đợi của ABPVN
  10. // @contributionURL https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=donghoang.nguyen@gmail.com&item_name=ABPVN Donation
  11. // @run-at document-end
  12. // @include http://*
  13. // @include https://*
  14. // @version 2.2.10.7
  15. // @change-log Remove popup block because no needed on anime47.com
  16. // @grant none
  17. // ==/UserScript==
  18. /* String Prototype */
  19. String.prototype.startWith = function strxStart(str) {
  20. return this.indexOf(str) === 0;
  21. };
  22. String.prototype.ismatch = function (regex) {
  23. return this.match(regex) !== null;
  24. };
  25. var getAllText = function (selector) {
  26. var text = '';
  27. var list = document.querySelectorAll(selector);
  28. if (list)
  29. for (var i = 0; i < list.length; i++) {
  30. text += list[i].innerText;
  31. }
  32. return text;
  33. };
  34. var removeDuplicates = function (arr) {
  35. var tmp = [
  36. ];
  37. for (var i = 0; i < arr.length; i++) {
  38. if (tmp.indexOf(arr[i]) == - 1) {
  39. tmp.push(arr[i]);
  40. }
  41. }
  42. return tmp;
  43. };
  44. //Bypass Class
  45. var byPass = {
  46. hideLinkUnlock: function () {
  47. var contentDiv = document.querySelectorAll('.onp-sl-content,.onp-locker-call,[data-locker-id]');
  48. if (contentDiv.length) {
  49. ABPVN.cTitle();
  50. //Add style tag to hide all .onp-sl and show all .onp-sl-content
  51. if (!document.getElementById('abpvn_style')) {
  52. var style = document.createElement('style');
  53. style.id = 'abpvn_style';
  54. style.innerHTML = '.onp-sl-content{display:block!important;}.onp-sl,.onp-sl-overlap-box{display:none!important;}';
  55. document.body.appendChild(style);
  56. } //ShowALl ContentDiv
  57.  
  58. for (var i in contentDiv) {
  59. if (contentDiv[i].firstChild && contentDiv[i].firstChild.innerText != 'Unlocked by ABPVN.COM') {
  60. var creditDiv = document.createElement('div');
  61. creditDiv.innerHTML = '<a href="http://abpvn.com" target="_blank" style="color: #08BE54;font-weight: bold;">Unlocked by ABPVN.COM</a>';
  62. creditDiv.style.textAlign = 'right';
  63. contentDiv[i].insertBefore(creditDiv, contentDiv[i].firstChild);
  64. }
  65. if(contentDiv[i].style){
  66. contentDiv[i].style.display = 'block';
  67. }
  68. } //Hide All LockDiv
  69.  
  70. var lockDiv = document.querySelectorAll('.onp-sl,div[id^="content-locker"]');
  71. for (var j in lockDiv) {
  72. if(lockDiv[j].style){
  73. lockDiv[j].style.display = 'none !important';
  74. lockDiv[j].setAttribute('hidden','hidden');
  75. }
  76. }
  77. }
  78. },
  79. anti123link: function(){
  80. var allShortLink = document.querySelectorAll('a[href^="http://123link"]');
  81. var count = 0;
  82. if(allShortLink.length){
  83. ABPVN.cTitle();
  84. for(var i=0;i<allShortLink.length;i++){
  85. var processingLink = allShortLink[i];
  86. var href = processingLink.getAttribute('href');
  87. var tmp = href.match(/url=(.+?)&|$/); ;
  88. if(tmp[1]){
  89. processingLink.setAttribute('href', atob(tmp[1]));
  90. var oldTitle = processingLink.getAttribute('title');
  91. processingLink.setAttribute('title',oldTitle?(oldTitle+' '):''+'123link by pass by ABPVN');
  92. count++;
  93. }
  94. }
  95. Logger.info("By pass "+count+" 123link short");
  96. }
  97. },
  98. init: function () {
  99. window.addEventListener('DOMContentLoaded', this.hideLinkUnlock);
  100. window.addEventListener('load', this.hideLinkUnlock);
  101. this.hideLinkUnlock();
  102. window.addEventListener('DOMContentLoaded', this.anti123link);
  103. }
  104. };
  105. //Logger Class
  106. var Logger = {
  107. info: function (text) {
  108. console.info('ABPVN Info: ', text);
  109. },
  110. warn: function (text) {
  111. console.warn('ABPVN Warn: ', text);
  112. },
  113. error: function (text) {
  114. console.error('ABPVN Error: ', text);
  115. },
  116. log: function (text) {
  117. console.log('ABPVN Log: ', text);
  118. },
  119. };
  120. //get Link class
  121. var getLink = {
  122. FShareConfig: function () {
  123. if (this.url.startWith('https://www.fshare.vn')) {
  124. var background_image = localStorage.off == 'true' ? 'url("http://i.imgur.com/kJnOMOB.png")' : 'url("http://i.imgur.com/2b7fN6a.png")';
  125. var title = localStorage.off == 'true' ? 'Bật get link fshare' : 'Tắt get link fshare';
  126. 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>';
  127. $(document).ready(function () {
  128. $(document.body).append(html);
  129. $(document).on('click', '#fs_click', function FS_on_off() {
  130. if (localStorage.off != 'true') {
  131. localStorage.off = true;
  132. this.style.backgroundImage = 'url("http://i.imgur.com/kJnOMOB.png")';
  133. this.setAttribute('title', 'Bật get link fshare');
  134. alert('Đã tắt get link fshare');
  135. }
  136. else {
  137. localStorage.off = false;
  138. this.setAttribute('title', 'Tắt get link fshare');
  139. this.style.backgroundImage = 'url("http://i.imgur.com/2b7fN6a.png")';
  140. alert('Đã bật get link fshare');
  141. }
  142. });
  143. });
  144. }
  145. },
  146. FShareGetLink: function () {
  147. if (this.url.startWith('https://www.fshare.vn/file/') && !this.url.startWith('https://www.fshare.vn/file/manager')) {
  148. if (localStorage.off != 'true') {
  149. console.info('Start get link Fshare.vn');
  150. $(document).ready(function () {
  151. var checkpassword = document.querySelector('.password-form');
  152. var linkcode = $('#linkcode').val();
  153. if (checkpassword === null) {
  154. var code = $('#form-download input[name="_csrf-app"]').val();
  155. var data = {
  156. '_csrf-app': code,
  157. 'fcode5': '',
  158. 'linkcode': linkcode,
  159. 'withFcode5': 0,
  160. };
  161. $.post('/download/get', data).done(function (data, statusText, xhr) {
  162. if (data.url === undefined) location.reload();
  163. else {
  164. if (typeof location != 'undefined') {
  165. console.log('ABPVN: ' + location.href + ' -> ' + data.url);
  166. location.href = data.url;
  167. }
  168. else {
  169. $('.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>'
  170. );
  171. }
  172. }
  173. }).fail(function (xhr, statusText, error) {
  174. alert('ABPVN: Đã có lỗi fshare hoặc file có password');
  175. });
  176. }
  177. else {
  178. alert('ABPVN: Hãy nhập mật khẩu cho file trước');
  179. }
  180. });
  181. }
  182. else {
  183. $('.download').prepend('<a title="Download nhanh qua linksvip.net" 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="http://linksvip.net?link=' + location.href + '">Tải nhanh<span>Qua dịch vụ linksvip.net</span></a>'
  184. );
  185. }
  186. }
  187. },
  188. mediafire_com: function () {
  189. if (this.url.startWith('http://www.mediafire.com/file/') || this.url.startWith('https://www.mediafire.com/file/')) {
  190. var a_tag = document.querySelector('.download_link a');
  191. var link = a_tag.getAttribute('href');
  192. if (link.startWith('http')) {
  193. 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>';
  194. location.href = link;
  195. }
  196. }
  197. },
  198. usercloud_com: function () {
  199. if (this.url.startWith('https://userscloud.com/') && this.url.length > 24) {
  200. var form = document.querySelector('form[name="F1"]');
  201. if (form) {
  202. form.submit();
  203. document.body.innerHTML = '<center><h1>ABPVN UserCloud Download đã hoạt động</h1><a href=\'http://abpvn.com/napthe\'><h1>Ủng hộ ABPVN</h1></center>';
  204. } else {
  205. var a_link = document.querySelector('h4 a.btn-success');
  206. if (a_link) {
  207. var link = a_link.getAttribute('href');
  208. if (link.startWith('https')) {
  209. location.href = link;
  210. 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>';
  211. }
  212. }
  213. }
  214. }
  215. },
  216. init: function () {
  217. this.url = location.href;
  218. this.FShareConfig();
  219. this.FShareGetLink();
  220. this.mediafire_com();
  221. this.usercloud_com();
  222. }
  223. };
  224. //Fix site class
  225. var fixSite = {
  226. elementExist: function (selector) {
  227. var check = document.querySelector(selector);
  228. return check != null;
  229. },
  230. getAllText: function (selector) {
  231. var text = '';
  232. var nodeList = document.querySelectorAll(selector);
  233. if (nodeList) {
  234. for (var i in nodeList) {
  235. if (nodeList[i].innerText) text += nodeList[i].innerText;
  236. }
  237. }
  238. return text;
  239. },
  240. getScript: function (url) {
  241. var xhr = new XMLHttpRequest();
  242. xhr.open('GET', url);
  243. xhr.addEventListener('load', function (data) {
  244. var blob = new Blob([xhr.responseText], {
  245. type: 'text/javascript'
  246. });
  247. var url = URL.createObjectURL(blob);
  248. var script = document.createElement('script');
  249. script.src = url;
  250. script.type = 'text/javascript';
  251. document.getElementsByTagName('head')[0].appendChild(script);
  252. });
  253. xhr.send();
  254. },
  255. loadCss: function (url, id) {
  256. var css_tag = document.createElement('link');
  257. css_tag.rel = 'stylesheet';
  258. css_tag.id = id;
  259. css_tag.href = url;
  260. var head = document.getElementsByTagName('head')[0];
  261. head.appendChild(css_tag);
  262. },
  263. phim_media: function () {
  264. if (this.url.startWith('https://www.phim.media/')||this.url.startWith('http://www.phim.media/')) {
  265. var links = document.querySelectorAll('#btn-film-watch,.poster > a');
  266. if(links){
  267. for(var i=0;i<links.length;i++){
  268. var href = links[i].getAttribute('href');
  269. href = href.match('utm_id=.*') [0].replace('utm_id=', '');
  270. if (href) {
  271. links[i].setAttribute('href', atob(href));
  272. }
  273. }
  274. ABPVN.cTitle();
  275. }
  276. }
  277. },
  278. linkneverdie_com: function () {
  279. if(this.url.startWith('https://linkneverdie.com/')){
  280. ABPVN.cTitle();
  281. var el=document.getElementById('wrapper');
  282. if(el){
  283. el.id="wrapper-fix-by-abpvn";
  284. }
  285. }
  286. },
  287. hdonline_vn: function(){
  288. if (this.url.startWith('http://hdonline.vn')) {
  289. var links = document.querySelectorAll('a[href^="http://hub.blueserving.com/"]');
  290. for (var i in links) {
  291. var link = links[i];
  292. var href = link.getAttribute('href');
  293. href = href.match('url=.*') [0].replace('url=', '');
  294. if (href) {
  295. link.setAttribute('href', href);
  296. }
  297. }
  298. ABPVN.cTitle();
  299. }
  300. },
  301. maclife_vn: function(){
  302. if(this.url.startWith('https://maclife.vn/')){
  303. var allShortUrl=document.querySelectorAll('a[rel]');
  304. var count=0;
  305. for(var i=0;i<allShortUrl.length;i++){
  306. if(allShortUrl[i].innerText.indexOf('http')===0){
  307. allShortUrl[i].setAttribute('href',allShortUrl[i].innerText);
  308. count++;
  309. }
  310. }
  311. Logger.info("Đã xóa "+count+" link rút gọn!");
  312. }
  313. },
  314. aphim_co: function(){
  315. if (this.url.startWith('https://aphim.co/xem-phim/')) {
  316. ABPVN.cTitle();
  317. var aTagAds = document.querySelector('#video > a');
  318. aTagAds.setAttribute('href','#abpvn');
  319. aTagAds.removeAttribute('target');
  320. Logger.info('Đã xóa link quảng cáo!');
  321. }
  322. },
  323. openload: function(){
  324. if(this.url.match(/^(https?:)?\/\/openload\.co\/*.*/) || this.url.match(/^(https?:)?\/\/oload\.\/*.*/)){
  325. //Base on https://greasyfork.org/vi/scripts/17665-openload
  326. //
  327. // @run-at document-start
  328. //
  329. window.adblock=false;
  330. window.adblock2=false;
  331. window.turnoff=true;
  332. window.open=function(){};
  333. //
  334. // @run-at document-end
  335. //
  336. function onready(fn){if(document.readyState!='loading')fn();else document.addEventListener('DOMContentLoaded',fn);}
  337.  
  338. onready(function(){
  339. if( document.location.href.match(/\/embed\//) || $('#realdl>a') )
  340. {
  341. var streamurl = '#streamurl,#streamuri,#streamurj,#adbdetect + script + div > p:nth-child(2)';
  342. $('#btnView').hide();
  343. $('#btnDl').hide();
  344. $('.dlButtonContainer').show();
  345. $('h3.dlfile.h-method').hide();
  346. $('.col-md-4.col-centered-sm *').remove();
  347. $('#mgiframe,#main>div[id*="Composite"]').remove();
  348. $('#downloadTimer').hide();
  349. $('#mediaspace_wrapper').prepend( $('<div/>').attr('id', 'realdl')
  350. .attr('style', 'position: absolute; top: 0 ; left: 0 ; right: 0; text-align: center; z-index: 9999; background-color: #00DC58; padding: .5em 0;')
  351. .on('mouseenter', function(){ $(this).fadeTo(500, 1); }).on('mouseleave', function(){ $(this).fadeTo(500, 0); })
  352. .append( $('<a/>').attr('href', '').attr('style', 'color: #fff; text-decoration: none;').html('FREE DOWNLOAD<sub>Power by abpvn.com</sub>') ) );
  353. if(document.location.href.match(/\/embed\//)){
  354. setTimeout(function(){
  355. $('#realdl').fadeTo(500,0);
  356. },1500);
  357. }
  358. $('#realdl').show();
  359. var tmrstreamurl = setInterval(function(){
  360. if($(streamurl).text() != '640K ought to be enough for anybody')
  361. {
  362. $('#realdl a').attr('href', '/stream/' + $(streamurl).text());
  363. $('#videooverlay').click();
  364. clearInterval(tmrstreamurl);
  365. }
  366. },100);
  367. }
  368. window.onclick=function(){};
  369. document.onclick=function(){};
  370. document.body.onclick=function(){};
  371. });
  372. }
  373. },
  374. fontdep_com: function(){
  375. if(this.url.startWith('http://www.fontdep.com/')&&document.cookie.indexOf('virallock_myid')==-1){
  376. document.cookie='virallock_myid=0001';
  377. location.reload();
  378. }
  379. },
  380. removeRedir(config) {
  381. if (this.url.match(new RegExp(config.url,'g')) || this.url.startWith(config.url)) {
  382. ABPVN.cTitle();
  383. var links = document.querySelectorAll('a[href^="' + config.replace + '"]');
  384. Logger.info('Remove Redirect for ' + links.length + ' links');
  385. if (links.length) {
  386. links.forEach(function (item) {
  387. var stockUrl = item.getAttribute('href').replace(config.replace, '');
  388. var count = 0;
  389. while (stockUrl.indexOf('%2') > - 1 && count < 5) {
  390. stockUrl = decodeURIComponent(stockUrl);
  391. count++;
  392. }
  393. item.setAttribute('href', stockUrl);
  394. item.setAttribute('title','Link đã xóa chuyển hướng trung gian bởi abpvn.com');
  395. }.bind(this));
  396. }
  397. }
  398. },
  399. removeRedirect() {
  400. var configs = [
  401. {
  402. url: 'https://samsungvn.com',
  403. replace: 'https://samsungvn.com/xfa-interstitial/redirect?url=',
  404. },
  405. {
  406. url: 'https://forum.vietdesigner.net',
  407. replace: 'redirect/?url='
  408. },
  409. {
  410. url: 'http://sinhvienit.net',
  411. replace: 'http://sinhvienit.net/goto/?'
  412. },
  413. {
  414. url: 'http://phanmemaz.com/',
  415. replace: 'http://phanmemaz.com/wp-content/plugins/tm-wordpress-redirection/l.php?'
  416. },
  417. {
  418. url: 'vozforums\.(com|net)',
  419. replace: '/redirect/index.php?link='
  420. }
  421. ];
  422. configs.forEach(function (config) {
  423. this.removeRedir(config);
  424. }.bind(this));
  425. },
  426. mgIdAdRemover: function(){
  427. var allMgIdEl = document.querySelectorAll('[id*="ScriptRoot"]');
  428. if(allMgIdEl && allMgIdEl.length){
  429. ABPVN.cTitle();
  430. for(var i = 0;i<allMgIdEl.length;i++){
  431. allMgIdEl[i].remove();
  432. }
  433. }
  434. },
  435. init: function () {
  436. this.url = location.href;
  437. this.mgIdAdRemover();
  438. this.removeRedirect();
  439. this.phim_media();
  440. this.linkneverdie_com();
  441. this.hdonline_vn();
  442. this.maclife_vn();
  443. this.aphim_co();
  444. this.fontdep_com();
  445. this.openload();
  446. }
  447. };
  448. //Main class
  449. var ABPVN = {
  450. getCookie: function (cookie_name) {
  451. var value = '; ' + document.cookie;
  452. var parts = value.split('; ' + cookiename + '=');
  453. if (parts.length == 2) return parts.pop().split(';').shift();
  454. },
  455. cTitle: function () {
  456. if (document.title.indexOf(' - Fixed by ABPVN.COM') == - 1) {
  457. document.title = document.title + ' - Fixed by ABPVN.COM';
  458. }
  459. },
  460. blockPopUp: function () {
  461. var listSite = [
  462. 'http://blogtruyen.com',
  463. 'http://www.khosachnoi.net',
  464. 'http://hamtruyen.vn/',
  465. 'http://phim14.net/',
  466. 'http://phim7.com/',
  467. 'http://www.diendan.trentroiduoidat.com/',
  468. 'http://www.trentroiduoidat.com/',
  469. 'http://chophanthiet.us',
  470. 'http://animetvn.com',
  471. 'http://font.vn',
  472. 'https://vidoza.net/',
  473. 'http://www.easysoft.xyz',
  474. 'http://hdonline.vn',
  475. 'https://www.phim.media',
  476. 'http://phimnhanh.com',
  477. 'http://www.vietsubhd.com'
  478. ];
  479. for (var i = 0; i < listSite.length; i++) {
  480. if (this.url.startWith(listSite[i])) {
  481. this.cTitle();
  482. Logger.info('Đã chặn popup quảng cáo');
  483. document.body.onclick = null;
  484. document.onclick = null;
  485. document.ontouchstart=null;
  486. document.onmousedown=null;
  487. window.addEventListener('load', function () {
  488. setTimeout(function () {
  489. Logger.info('Đã chặn popup quảng cáo onload');
  490. document.ontouchstart=null;
  491. document.onclick = null;
  492. document.body.onclick = null;
  493. document.onmousedown=null;
  494. }, 300);
  495. });
  496. window.addEventListener('DOMContentLoaded', function () {
  497. setTimeout(function () {
  498. Logger.info('Đã chặn popup quảng cáo dom load');
  499. document.ontouchstart=null;
  500. document.onclick = null;
  501. document.body.onclick = null;
  502. document.onmousedown=null;
  503. }, 300);
  504. });
  505. }
  506. }
  507. },
  508. init: function () {
  509. this.url = location.href;
  510. this.blockPopUp();
  511. //Init class getLink
  512. getLink.init();
  513. //Init class Fixsite
  514. fixSite.init();
  515. //console.info('ABVPN init finish for: '+this.url);
  516. byPass.init();
  517. }
  518. };
  519. //RUN INNIT
  520. ABPVN.init();