Greasy Fork is available in English.

ABPVN AdsBlock

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

2017/02/22のページです。最新版はこちら。

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