Greasy Fork is available in English.

ABPVN AdsBlock

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

La data de 05-07-2017. Vezi ultima versiune.

  1. // ==UserScript==
  2. // @name ABPVN AdsBlock
  3. // @namespace ABPVN
  4. // @author Hoàng Rio
  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.1.3
  15. // @noframes
  16. // @change-log Update unlock hidden content for multi block
  17. // @grant none
  18. // ==/UserScript==
  19. /* String Prototype */
  20. String.prototype.startWith = function strxStart(str) {
  21. return this.indexOf(str) === 0;
  22. };
  23. String.prototype.ismatch = function (regex) {
  24. return this.match(regex) !== null;
  25. };
  26. var getAllText = function (selector) {
  27. var text = '';
  28. var list = document.querySelectorAll(selector);
  29. if (list)
  30. for (var i = 0; i < list.length; i++) {
  31. text += list[i].innerText;
  32. }
  33. return text;
  34. };
  35. var removeDuplicates = function (arr) {
  36. var tmp = [
  37. ];
  38. for (var i = 0; i < arr.length; i++) {
  39. if (tmp.indexOf(arr[i]) == - 1) {
  40. tmp.push(arr[i]);
  41. }
  42. }
  43. return tmp;
  44. };
  45. //Bypass Class
  46. var byPass = {
  47. hideLink: function () {
  48. var contentDiv = document.querySelectorAll('.onp-sl-content');
  49. if (contentDiv.length) {
  50. ABPVN.cTitle();
  51. //ShowALl ContentDiv
  52. for (var i in contentDiv) {
  53. var creditDiv = document.createElement('div');
  54. creditDiv.innerHTML = '<a href="http://abpvn.com" target="_blank" style="color: #08BE54;font-weight: bold;">Unlocked by ABPVN.COM</a>';
  55. creditDiv.style.textAlign = 'right';
  56. contentDiv[i].insertBefore(creditDiv, contentDiv[i].firstChild);
  57. contentDiv[i].style.display = 'block';
  58. } //Hide All LockDiv
  59.  
  60. var lockDiv = document.querySelectorAll('.onp-sl');
  61. for (var i in lockDiv) {
  62. lockDiv[i].style.display = 'none';
  63. }
  64. }
  65. },
  66. init: function () {
  67. window.addEventListener('DOMContentLoaded', this.hideLink);
  68. window.addEventListener('load', this.hideLink);
  69. }
  70. };
  71. //Logger Class
  72. var Logger = {
  73. info: function (text) {
  74. console.info('ABPVN Info: ', text);
  75. },
  76. warn: function (text) {
  77. console.warn('ABPVN Warn: ', text);
  78. },
  79. error: function (text) {
  80. console.error('ABPVN Error: ', text);
  81. },
  82. log: function (text) {
  83. console.log('ABPVN Log: ', text);
  84. },
  85. };
  86. //get Link class
  87. var getLink = {
  88. FShareConfig: function () {
  89. if (this.url.startWith('https://www.fshare.vn')) {
  90. var background_image = localStorage.off == 'true' ? 'url("http://i.imgur.com/kJnOMOB.png")' : 'url("http://i.imgur.com/2b7fN6a.png")';
  91. var title = localStorage.off == 'true' ? 'Bật get link fshare' : 'Tắt get link fshare';
  92. 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: 9999;\'></div>';
  93. $(document).ready(function () {
  94. $(document.body).append(html);
  95. $(document).on('click', '#fs_click', function FS_on_off() {
  96. if (localStorage.off != 'true') {
  97. localStorage.off = true;
  98. this.style.backgroundImage = 'url("http://i.imgur.com/kJnOMOB.png")';
  99. this.setAttribute('title', 'Bật get link fshare');
  100. alert('Đã tắt get link fshare');
  101. }
  102. else {
  103. localStorage.off = false;
  104. this.setAttribute('title', 'Tắt get link fshare');
  105. this.style.backgroundImage = 'url("http://i.imgur.com/2b7fN6a.png")';
  106. alert('Đã bật get link fshare');
  107. }
  108. });
  109. });
  110. }
  111. },
  112. FShareGetLink: function () {
  113. if (this.url.startWith('https://www.fshare.vn/file/')) {
  114. if (localStorage.off != 'true') {
  115. console.info('Start get link Fshare.vn');
  116. $(document).ready(function () {
  117. var checkpassword = document.querySelector('.fa-lock');
  118. var linkcode = $('[data-linkcode]').attr('data-linkcode');
  119. if (checkpassword === null) {
  120. var code = $('input[name=fs_csrf]').val();
  121. var speed = $(this).data('speed');
  122. var data = {
  123. 'fs_csrf': code,
  124. 'DownloadForm[pwd]': '',
  125. 'DownloadForm[linkcode]': linkcode,
  126. 'ajax': 'download-form',
  127. 'undefined': 'undefined'
  128. };
  129. $.post('/download/get', data).done(function (data, statusText, xhr) {
  130. if (data.url === undefined) location.reload();
  131. else {
  132. if (typeof location != 'undefined') {
  133. console.log('ABPVN: ' + location.href + ' -> ' + data.url);
  134. location.href = data.url;
  135. }
  136. else {
  137. $('.policy_download').prepend('<div class="col-xs-12"><a title="Download nhanh qua linksvip.net" style="margin-top: 10px; height: 70px;" class="btn btn-success btn-lg btn-block btn-download-sms" href="' + data.url + '"> <i class="fa fa-cloud-download fa-2x pull-left"></i> <span class="pull-right text-right download-txt"> Tải trực tiếp<br> <small>Hỗ trợ bởi abpvn.com</small> </span></a></div>'
  138. );
  139. }
  140. }
  141. }).fail(function (xhr, statusText, error) {
  142. $.alert({
  143. success: false,
  144. message: 'ABPVN: Đã có lỗi fshare hoặc file có password'
  145. });
  146. });
  147. }
  148. else {
  149. $.alert({
  150. success: false,
  151. message: 'ABPVN: Hãy nhập mật khẩu cho file trước'
  152. });
  153. $('#download-form').unbind('submit');
  154. $('#download-form').submit(function (event) {
  155. var pwd = $('#DownloadForm_pwd').val();
  156. var code = $('input[name=fs_csrf]').val();
  157. var speed = $(this).data('speed');
  158. var data = {
  159. 'fs_csrf': code,
  160. 'DownloadForm[pwd]': pwd,
  161. 'DownloadForm[linkcode]': linkcode,
  162. 'ajax': 'download-form',
  163. 'undefined': 'undefined'
  164. };
  165. $.post('/download/get', data).done(function (data, statusText, xhr) {
  166. if (data.url === undefined) location.reload();
  167. else {
  168. if (typeof location != 'undefined') {
  169. console.log('ABPVN: ' + location.href + ' -> ' + data.url);
  170. location.href = data.url;
  171. }
  172. else {
  173. $('.policy_download').prepend('<div class="col-xs-12"><a title="Download nhanh qua linksvip.net" style="margin-top: 10px; height: 70px;" class="btn btn-success btn-lg btn-block btn-download-sms" href="' + data.url + '"> <i class="fa fa-cloud-download fa-2x pull-left"></i> <span class="pull-right text-right download-txt"> Tải trực tiếp<br> <small>Hỗ trợ bởi abpvn.com</small> </span></a></div>'
  174. );
  175. }
  176. }
  177. }).fail(function (xhr, statusText, error) {
  178. $.alert({
  179. success: false,
  180. message: 'ABPVN: Đã có lỗi fshare hoặc file có password'
  181. });
  182. });
  183. event.preventDefault();
  184. });
  185. }
  186. });
  187. }
  188. else {
  189. $('.policy_download').prepend('<div class="col-xs-12"><a title="Download nhanh qua linksvip.net" style="margin-top: 10px; height: 70px;" class="btn btn-success btn-lg btn-block btn-download-sms" href="http://linksvip.net?link=' + location.href + '"> <i class="fa fa-cloud-download fa-2x pull-left"></i> <span class="pull-right text-right download-txt"> Tải nhanh<br> <small>Qua dịch vụ linksvip.net</small> </span></a></div>'
  190. );
  191. }
  192. }
  193. },
  194. mediafire_com: function () {
  195. if (this.url.startWith('http://www.mediafire.com/file/')) {
  196. var a_tag = document.querySelector('.download_link a');
  197. var link = a_tag.getAttribute('href');
  198. if (link.startWith('http')) {
  199. 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>';
  200. location.href = link;
  201. }
  202. }
  203. },
  204. usercloud_com: function () {
  205. if (this.url.startWith('https://userscloud.com/') && this.url.length > 24) {
  206. var form = document.querySelector('form[name="F1"]');
  207. if (form) {
  208. form.submit();
  209. document.body.innerHTML = '<center><h1>ABPVN UserCloud Download đã hoạt động</h1><a href=\'http://abpvn.com/napthe\'><h1>Ủng hộ ABPVN</h1></center>';
  210. } else {
  211. var a_link = document.querySelector('h4 a.btn-success');
  212. if (a_link) {
  213. var link = a_link.getAttribute('href')
  214. if (link.startWith('https')) {
  215. location.href = link;
  216. 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>';
  217. }
  218. }
  219. }
  220. }
  221. },
  222. init: function () {
  223. this.url = location.href;
  224. this.FShareConfig();
  225. this.FShareGetLink();
  226. this.mediafire_com();
  227. this.usercloud_com();
  228. }
  229. };
  230. //Fix site class
  231. var fixSite = {
  232. elementExist: function (selector) {
  233. var check = document.querySelector(selector);
  234. return check != null;
  235. },
  236. getAllText: function (selector) {
  237. var text = '';
  238. var nodeList = document.querySelectorAll(selector);
  239. if (nodeList) {
  240. for (var i in nodeList) {
  241. if (nodeList[i].innerText) text += nodeList[i].innerText;
  242. }
  243. }
  244. return text;
  245. },
  246. getScript: function (url) {
  247. var xhr = new XMLHttpRequest();
  248. xhr.open('GET', url);
  249. xhr.addEventListener('load', function (data) {
  250. var blob = new Blob([xhr.responseText], {
  251. type: 'text/javascript'
  252. });
  253. var url = URL.createObjectURL(blob);
  254. var script = document.createElement('script');
  255. script.src = url;
  256. script.type = 'text/javascript';
  257. document.getElementsByTagName('head') [0].appendChild(script);
  258. });
  259. xhr.send();
  260. },
  261. loadCss: function (url, id) {
  262. var css_tag = document.createElement('link');
  263. css_tag.rel = 'stylesheet';
  264. css_tag.id = id;
  265. css_tag.href = url;
  266. var head = document.getElementsByTagName('head') [0];
  267. head.appendChild(css_tag);
  268. },
  269. talktv_vn: function () {
  270. if (this.url.startWith('http://talktv.vn/') && this.url.length > 17) {
  271. //disabled jwplayer
  272. //jwplayer = {
  273. // };
  274. $(document).ready(function () {
  275. if (loadPlayer.manifestUrl.indexOf('.m3u8') != - 1) {
  276. //Ininit Libs Tag
  277. var css_tag = document.createElement('link');
  278. css_tag.rel = 'stylesheet';
  279. css_tag.href = 'https://cdnjs.cloudflare.com/ajax/libs/video.js/6.0.1/video-js.min.css';
  280. var script_vjs_tag = document.createElement('script');
  281. script_vjs_tag.src = 'https://cdnjs.cloudflare.com/ajax/libs/video.js/6.0.1/video.min.js';
  282. var script_js_hls = document.createElement('script');
  283. script_js_hls.src = 'https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-hls/5.5.0/videojs-contrib-hls.js';
  284. //script_js_hls.src = 'https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-hls/3.7.0-beta4/videojs-contrib-hls.js';
  285. var head = document.getElementsByTagName('head') [0];
  286. head.appendChild(css_tag);
  287. head.appendChild(script_vjs_tag);
  288. head.appendChild(script_js_hls);
  289. //Innit video Tag to play
  290. document.querySelector('.channel-play').innerHTML = '<video controls id="abpvn_talktv_vjs" autoplay="autoplay" style="width: 100%; height: 100%" class="video-js vjs-default-skin" poster="' + loadPlayer.backgroundImage + '"><source src="http://crossorigin.me/' + loadPlayer.manifestUrl + '" type="application/x-mpegURL"></video>';
  291. var timer;
  292. timer = setInterval(function () {
  293. if (typeof videojs != 'undefined' && typeof videojs.Hls != 'undefined') {
  294. var tmp_video = videojs('abpvn_talktv_vjs');
  295. tmp_video.play();
  296. clearInterval(timer);
  297. }
  298. }, 300);
  299. }
  300. });
  301. }
  302. },
  303. tv_zing_vn: function () {
  304. if (this.url.startWith('http://tv.zing.vn/video/') && !this.elementExist('#_infoUserCp') && !MP3.ZINGTV_VIP) {
  305. window.addEventListener('DOMContentLoaded', function () {
  306. var script = document.createElement('script');
  307. script.src = 'https://content.jwplatform.com/libraries/QHJ5Iarr.js';
  308. script.type = 'text/javascript';
  309. document.getElementsByTagName('head') [0].appendChild(script);
  310. //get video list
  311. var text = getAllText('script');
  312. var quality = [
  313. '360',
  314. '480',
  315. '720',
  316. '1080'
  317. ];
  318. var listVideo = text.match(/http:\/\/stream\d+\.tv.+?\.mp4/g);
  319. listVideo = removeDuplicates(listVideo);
  320. var sources = [
  321. ];
  322. for (var i = 0; i < listVideo.length; i++) {
  323. sources.push({
  324. 'file': listVideo[i],
  325. 'label': quality[i]
  326. })
  327. };
  328. //get Image poster
  329. var imagePoster = text.match(/http:\/\/image.+?\.jpg/);
  330. //Setup Player
  331. var playerId = 'abpvn_player';
  332. document.getElementById('player').innerHTML = '<div id="' + playerId + '"></div>';
  333. var clock = setInterval(function () {
  334. if (typeof jwplayer != 'undefined') {
  335. jwplayer(playerId).setup({
  336. sources: sources,
  337. autostart: true,
  338. image: imagePoster[0],
  339. width: '100%',
  340. height: 520
  341. })
  342. clearInterval(clock);
  343. }
  344. }, 300);
  345. });
  346. }
  347. },
  348. hamtruyen_vn: function () {
  349. if (this.url.startWith('http://hamtruyen.vn/')) {
  350. document.addEventListener('DOMContentLoaded', function () {
  351. ABPVN.Logger.log('Run block popup');
  352. var container = document.getElementById('container');
  353. if (container) {
  354. var btpop = function () {
  355. ABPVN.Logger.info('Overided Popup Function');
  356. };
  357. $('#container').click(function () {
  358. });
  359. container.onclick = null;
  360. }
  361. });
  362. }
  363. },
  364. _2idol_tv: function () {
  365. if ((this.url.startWith('http://2idol.tv/post/') || this.url.startWith('http://video.2idol.tv/post-video/')) && navigator.userAgent.match(/Firefox/i) != null) {
  366. Logger.info('Fix 2idol.tv player on Firefox');
  367. ABPVN.cTitle();
  368. document.querySelector('#vod').setAttribute('id', 'abpvn_fixed');
  369. window.addEventListener('DOMContentLoaded', function () {
  370. var scriptText = this.getAllText('script');
  371. var file = scriptText.match(/https:\/\/www\.youtube\.com\/watch\?v=[\w-]+/i) [0];
  372. var style_url = URL.createObjectURL(new Blob(['.jwlogo {width: 50px; height: 50px; opacity: 0.7 !important;a}'], {
  373. type: 'text/css'
  374. }));
  375. this.loadCss(style_url, 'fix_logo');
  376. if (file) {
  377. jwplayer('abpvn_fixed').setup({
  378. volume: '100',
  379. menu: 'true',
  380. allowscriptaccess: 'always',
  381. wmode: 'opaque',
  382. file: file,
  383. //file: "SampleVideo_1280x720_1mb.mp4",
  384. image: '',
  385. width: '663',
  386. height: '366',
  387. autostart: 'true',
  388. primary: 'html5',
  389. skin: 'http://' + location.hostname + '/public/player/jwplayer/bekle/bekle.xml',
  390. logo: {
  391. file: 'http://abpvn.com/icon.png',
  392. link: 'http://abpvn.com/',
  393. width: 30,
  394. height: 30,
  395. position: 'top-right'
  396. }
  397. });
  398. }
  399. }.bind(this));
  400. }
  401. },
  402. removeRedir(config) {
  403. if (this.url.startWith(config.url)) {
  404. ABPVN.cTitle();
  405. var links = document.querySelectorAll('a[href^="' + config.replace + '"]');
  406. Logger.info('Remove Redirect for ' + links.length + ' links');
  407. if (links.length) {
  408. links.forEach(function (item) {
  409. var stockUrl = item.getAttribute('href').replace(config.replace, '');
  410. var count = 0;
  411. while (stockUrl.indexOf('%2') > - 1 && count < 5) {
  412. stockUrl = decodeURIComponent(stockUrl);
  413. count++;
  414. }
  415. item.setAttribute('href', stockUrl);
  416. }.bind(this));
  417. }
  418. }
  419. },
  420. removeRedirect() {
  421. var configs = [
  422. {
  423. url: 'https://samsungvn.com',
  424. replace: 'https://samsungvn.com/xfa-interstitial/redirect?url=',
  425. },
  426. {
  427. url: 'https://forum.vietdesigner.net',
  428. replace: 'redirect/?url='
  429. },
  430. {
  431. url: 'http://sinhvienit.net',
  432. replace: 'http://sinhvienit.net/goto/?'
  433. },
  434. {
  435. url: 'http://phanmemaz.com/',
  436. replace: 'http://phanmemaz.com/wp-content/plugins/tm-wordpress-redirection/l.php?'
  437. }
  438. ];
  439. configs.forEach(function (config) {
  440. this.removeRedir(config);
  441. }.bind(this));
  442. },
  443. init: function () {
  444. this.url = location.href;
  445. this.talktv_vn();
  446. this.tv_zing_vn();
  447. this.hamtruyen_vn();
  448. this.removeRedirect();
  449. this._2idol_tv();
  450. }
  451. };
  452. //Main class
  453. var ABPVN = {
  454. getCookie: function (cookie_name) {
  455. var value = '; ' + document.cookie;
  456. var parts = value.split('; ' + cookiename + '=');
  457. if (parts.length == 2) return parts.pop().split(';').shift();
  458. },
  459. cTitle: function () {
  460. if (document.title.indexOf(' - Fixed by ABPVN.COM') == - 1) {
  461. document.title = document.title + ' - Fixed by ABPVN.COM';
  462. }
  463. },
  464. blockPopUp: function () {
  465. var listSite = [
  466. 'http://blogtruyen.com',
  467. 'http://www.khosachnoi.net',
  468. 'http://hamtruyen.vn/',
  469. 'http://phim14.net/',
  470. 'http://phim7.com/',
  471. 'http://www.diendan.trentroiduoidat.com/',
  472. 'http://www.trentroiduoidat.com/',
  473. 'http://chophanthiet.us',
  474. 'http://anime47.com/',
  475. 'http://animetvn.com',
  476. 'http://font.vn'
  477. ];
  478. for (var i = 0; i < listSite.length; i++) {
  479. if (this.url.startWith(listSite[i])) {
  480. this.cTitle();
  481. console.info('ABPVN: Đã chặn popup quảng cáo');
  482. document.body.onclick = null;
  483. window.addEventListener('load', function () {
  484. setTimeout(function () {
  485. document.body.onclick = null;
  486. }, 100);
  487. });
  488. }
  489. }
  490. },
  491. init: function () {
  492. this.url = location.href;
  493. this.blockPopUp();
  494. //Init class getLink
  495. getLink.init();
  496. //Init class Fixsite
  497. fixSite.init();
  498. //console.info('ABVPN init finish for: '+this.url);
  499. byPass.init();
  500. }
  501. };
  502. //RUN INNIT
  503. ABPVN.init();