M3u8

解析 或 破解 vip影视 的时候,使用的 《在线播放器》 和 《在线VIP解析接口》 和 《第三方影视野鸡网站》 全局通用 拦截和过滤 (解析资源/采集资源) 的 插播广告切片

  1. // ==UserScript==
  2. // @name M3u8
  3. // @description:en 不推荐手机浏览器使用,特别是没有安装 猴子 的 那种套壳浏览器
  4. // @description 解析 或 破解 vip影视 的时候,使用的 《在线播放器》 和 《在线VIP解析接口》 和 《第三方影视野鸡网站》 全局通用 拦截和过滤 (解析资源/采集资源) 的 插播广告切片
  5. // @version 20250615
  6. // @author 江小白
  7. // @include /\.php\?vod_id=\d+?$/
  8. // @include /\/\?id=[a-zA-Z\d]+?$/
  9. // @include /\/[pP]lay(?:er)?(?:\/|\?id=\d)/
  10. // @include /(?:lay|ideo).*?\.html/
  11. // @include /\.m3u8(?:\?(?!.+?&)|$)/
  12. // @include /^https?:\/\/[^\/]+?\/$/
  13. // @include /^https?:\/\/(?:movie\.douban\.com\/subject|m\.douban\.com\/movie)\//
  14. // @include /^https?:\/\/.+?(?<!(?:refer(?:rer)?|ori(?:gin)?))[&#=\?]https?(?::\/\/|:\\\/\\\/|%(?:3A|25)[^\/]+?)/
  15. // @include /^https?:\/\/(?!.+?https?(?::\/\/|:\\\/\\\/|%(?:3A|25)[^\/]+?)).+?[\?&](?:url|rul)=(?!http).{5,}/
  16. // @include /^https?:\/\/[^\/]+?\/{1,}(?:[pP]lay|[sS]hare)\/{1,}[a-zA-Z0-9]+?\/?\s*?$/
  17. // @include /^https?:\/\/[^\/]+?\/{1,}vod(?:\/{1,}[^\/]+?(?:\/{1,}\d[^\/]+?\d)?\.html|detail\/{1,}\d[^\/]+?\d\.html)/
  18. // @include /^https?:\/\/(?!.+?https?(?::\/\/|:\\\/\\\/|%(?:3A|25)[^\/]+?)).+?\/{1,}(?:index\.php\/{1,}vod\/{1,}detail\/{1,}id\/{1,}\d+?|p\/{1,}\d[^\.]+?\d)\.html/
  19. // @exclude /^https?:\/\/(?:[^\/]+?\.)?(?:(?:ggpht|qpic|gstatic|[yg]timg|youtu|google|cloudflare)|(?:roajsdl|vvvdj|bing|jd|tmall|taobao|meizu|asus|nike|vmall|fliggy|adidas|gome|\w*?suning|liangxinyao|xiaomiyoupin|mmstat|\w*?video\w*?\.qq)\.)/
  20. // @exclude /^https?:\/\/(?:.+?\]|(?:[^\/]+?\/{1,}(?!api)){1,}\w+?\?\w*?id=.+?(?<!&key=.+?)[&#=\?]https?(?::\/\/|:\\\/\\\/|%(?:3A|25)[^\/]+?)|(?:[^\/]+?\/{1,}(?:proxyhttp|[a-zA-Z]*?kv\?)|.+?\.\w+?\/{1,}\d+?)$)/
  21. // @exclude /(?:^https?:\/\/(?!.+?https?(?::\/\/|:\\\/\\\/|%(?:3A|25)[^\/]+?)).+?\.(?:ts|vob|3gp|rmvb|flac|[fh]lv|og[gv]|m(?:3u8|p[34]|kv|4a|ov|pg|idi|peg)|w(?:[am]v|ma|ebm)|a(?:ac|pe|vi|lac))|\.(?:js(?:on)?|rb|swf|png|xml|bmp|pac|gif|apk|exe|zip|txt|aspx|docx?|jpe?g|p(?:y|df|ng)|i(?:co|dx|mage)|r(?:ss|ar|[0-9]{2,2})|s(?:h|vg|rt|ub)|(?:c|le)ss|w(?:ebp|off2)))(?:#|\?|\\|&|$)|\/0\/(?:\d+?_){1,}\d+?\/0$/
  22. // @run-at document-start
  23. // @namespace https://greasyfork.org/users/769699
  24. // ==/UserScript==
  25.  
  26. (function() {
  27. try {
  28. if (typeof location['m3u8去插播广告'] === 'undefined') {
  29. try {
  30. Object.defineProperty(location, 'm3u8去插播广告', {
  31. value: 'm3u8去插播广告',
  32. writable: false,
  33. enumerable: false,
  34. configurable: false
  35. });
  36. } catch (e) {}
  37. try {
  38. if (typeof Proxy === 'function') {
  39. let m3u8wz, wzm3u8, mp4wz, flvwz, tswz, playsharewz, urlFromArgBy, ggbmd, shouldStopExecution, 打印开关, spbfurl, gggzdp, gggzpd, ggsjgg, ggzlhx, ggljbmd, ggljdmb, hhzz, bhhzz, dypd, m3u8gglj, m3u8ggljdypd, m3u8bflj;
  40. m3u8gglj = '';
  41. m3u8bflj = '';
  42. hhzz = '[\\n\\r\\u0085\\u2028\\u2029]';
  43. bhhzz = '[^\\n\\r\\u0085\\u2028\\u2029]';
  44. wzm3u8 = /\.m3u8(?:\?(?!.+?&)|$)/i;
  45. m3u8wz = /\.(?:m3u8|png|css)(?:#|\?|\\|&|$)|(?<!thread|forum|read)\.php(?!(?:[a-z0-9\/]|\?\w+?=.+?\.(?:m(?:p4|kv)|flv|ts)(?:#|\?|\\|&|$)))|\/(?!.+?\.m(?:3u8|p4)(?:#|\?|\\|&|$)).+?(?<![a-z0-9])m(?:3u8|p4)(?![a-z0-9])/i;
  46. mp4wz = /\.m(?:p4|kv)(?:#|\?|\\|&|$)|^https?:\/\/(?:[^\/]+?\.)?pstatp.+?\/obj\/[^\.]+?$|type=video_mp4&(?!.+\.[a-z]{2,5}(?:#|\?|\\|&|$))|\.php\?\w+?=.+?\.mp4/i;
  47. flvwz = /\.flv(?:#|\?|\\|&|$)/i;
  48. tswz = /\.ts(?:#|\?|\\|&|$)/i;
  49. playsharewz = /^https?:\/\/[^\/]+?\/{1,}(?:play|share)\/{1,}[a-zA-Z0-9]+?(?:\/{1,})?$/i;
  50. dypd = /^\s*?(?:0{1,}|(?<!开\s*?)关(?:\s*?[闭掉])?)\s*?$/;
  51. 打印开关 = '关';
  52. ggsjgg = '4|20';
  53. ggzlhx = 'ts|png|jpe?g|txt';
  54. ggljbmd = /&(?:[a-z]*?(?:sign|token|version)|[a-z]+?_?key)=/i;
  55. ggbmd = /(?:\.php|\_(?:ts|mp4)\/.+?\.m3u8)(?:#|\?|\\|&|$)/i;
  56. ggljdmb = new RegExp('\\.(?:' + ggzlhx + ')' + hhzz + '+?#EXTINF','i');
  57. shouldStopExecution = false;
  58. try {
  59. if (!shouldStopExecution) {
  60. /*以下是 M3U8 插播广告 过滤核心代码 不懂勿动*/
  61. const tyad0 = '#EXTINF'
  62. , tyad1 = tyad0 + '\\s*?:\\s*?'
  63. , tyad2 = '#EXT-X-DISCONTINUITY'
  64. , tyad3 = tyad2 + hhzz
  65. , tyad4 = '(?:' + ggzlhx + ')'
  66. , tyad5 = '\\.' + tyad4
  67. , tyad6 = tyad5 + hhzz + '+'
  68. , tyad7 = '#EXT-X-ENDLIST'
  69. , tyad8 = '(?:[a-z\\d]+?(?:\\s*?[\\_\\-]\\s*?)?)?\\d+?'
  70. , tyad9 = '#EXT-X-TARGETDURATION'
  71. , tyad10 = new RegExp('^\\s*?(?:(?!.*?0{3,})[a-z\\d]+?|' + tyad8 + '|https?:\\\/\\\/' + bhhzz + '+?0{3,}\\d+?)\\s*?$','i')
  72. , tyad11 = new RegExp('^' + tyad0,'i')
  73. , tyad12 = new RegExp('^\\s*?' + tyad1,'i')
  74. , tyad13 = '[\\S\\s]+?'
  75. , tyad14 = new RegExp(tyad8 + tyad5,'i')
  76. , tyad15 = '#EXT-X-PLAYLIST-TYPE'
  77. , tyada = bhhzz + '+?' + tyad6
  78. , tyadb = tyad1 + '\\d+?(?:\\.\\d+?)?\\s*?,' + hhzz + '+?'
  79. , tyadc = tyad3 + '+'
  80. , tyadd = tyadc + '?' + tyadb
  81. , tyade = tyada + '?[\\s\\S]*?' + tyadc
  82. , tyadf = '(?<=' + tyad9 + '\\s*?:\\s*?'
  83. , tyadg = ')(?:\\.0{1,})?\\s*?,'
  84. , tyadh = '(?:#EXT-X-[^:]+?:\\s*?'
  85. , tyadi = tyad1 + '\\d+?\\.\\d+?'
  86. , tyad100 = ggsjgg + tyadg
  87. , tyad101 = hhzz + '+?' + tyadh + bhhzz
  88. , tyad102 = tyad1 + '(?:' + tyad100 + hhzz
  89. , tyad103 = tyad101 + '+?' + hhzz
  90. , tyad104 = tyad1 + '\\d+?(?:\\.\\d+?)?,'
  91. , tyad105 = 'https?:\\\/\\\/'
  92. , tyad106 = '+?\\\/\\d+?_\\w{1,10}\\.ts'
  93. , tyad107 = new RegExp('^((?:' + bhhzz + '+?|\\s*?))(?=0{3}\\d+?' + tyad5 + ')','i')
  94. , tyad108 = '[a-z\\d]{10,}0{2}\\d+?\\.'
  95. , tyad109 = '(?:(?=' + tyad7 + ')|' + tyad3 + ')'
  96. , tyad1010 = '^\\s*?#EXTM3U\\s*?'
  97. , tyad1011 = hhzz + '+?' + bhhzz + '+?'
  98. , tyad1012 = tyad1011 + hhzz + '+?'
  99. , tyad1013 = tyad104 + tyad1012 + ')'
  100. , tyad1014 = tyad3 + '+?'
  101. , tyad1015 = tyad104 + hhzz + '+?'
  102. , tyad1016 = tyad6 + '?'
  103. , tyad1017 = bhhzz + '+?' + hhzz + '+?'
  104. , tyad1018 = '0{3}'
  105. , tyad1019 = tyad1011 + hhzz + '+?'
  106. , tyad1020 = tyad104 + tyad1019
  107. , tyad1021 = '#EXT-X-KEY\\s*?:\\s*?METHOD\\s*?='
  108. , tyad1022 = bhhzz + '+?' + tyad5
  109. , tyad1023 = '(?<=' + hhzz + '+)' + tyad1022
  110. , tyad1024 = tyad105 + bhhzz
  111. , tyad1025 = tyad1022 + hhzz + '+?'
  112. , tyad1026 = '(?<=' + hhzz + '+)' + tyad1014 + tyad1
  113. , tyad1027 = hhzz + '+?' + tyad105
  114. , tyad1028 = tyad1027 + tyad1017
  115. , tyad1029 = tyad1011 + tyad1016
  116. , tyad1030 = tyad1015 + tyad1024 + tyad106 + hhzz
  117. , tyad1031 = tyad1010 + hhzz + '+?'
  118. , tyad1032 = tyad1031 + '(?:#EXT-X-' + tyad1017 + '){1,}('
  119. , tyad1033 = tyad1011 + '(?<!' + tyad1018 + bhhzz + '+?)'
  120. , tyad1034 = tyad1033 + hhzz + '+?'
  121. , tyad1035 = tyad1033 + tyad5 + hhzz + '+?'
  122. , tyad1036 = tyadb + tyad1025
  123. , tyad1037 = tyad1028 + '(?:' + tyad1
  124. , tyad1038 = hhzz + '+?' + tyad1024 + '+?' + hhzz + '+?'
  125. , tyad1039 = tyadb + tyad1024 + '+?'
  126. , tyad1040 = tyad1029 + tyad1
  127. , tyad1041 = tyad1 + '\\d+?(?:\\.0{1,})?,'
  128. , tyad1042 = '(?:' + tyad1041 + tyad1038 + ')'
  129. , tyad1043 = tyadi + '\\s*?,' + hhzz
  130. , tyad1044 = '+?[a-z\\d]+?' + tyad6 + '?'
  131. , tyad1045 = tyad1043 + tyad1044 + '){'
  132. , tyad1046 = '\\s*?,' + hhzz + tyad1044
  133. , tyad1047 = '(?=#EXT-X-)'
  134. , tyad1048 = '){0,}'
  135. , tyad1049 = tyad1048 + tyad1 + '\\d+?\\.3{3,}\\s*?,'
  136. , tyad1050 = tyad1046 + '(?:' + tyad1043 + tyad1044 + tyad1048 + ')'
  137. , tyad1051 = new RegExp(tyad1010 + tyad13 + tyad5 + '(?:\\?' + bhhzz + '+?)?' + hhzz + '+?' + tyad1 + tyad13 + tyad7 + '\\s*?$','i')
  138. , tyad1052 = tyadb + tyad1017
  139. , tyad1053 = new RegExp(tyad1022,'gi')
  140. , tyad1054 = '(?<=^\\s*?\\d\\.\\d)3{3,}\\s*?$'
  141. , tyad1055 = new RegExp(tyad1054,'')
  142. , tyad1056 = new RegExp('(?<!\\d)\\d\\.\\d(\\d)\\1{2,}(?!\\1)\\d\\s*?$','')
  143. , itemts = new RegExp(tyad5,'i')
  144. , itemm3u8 = new RegExp(tyad1010 + '#EXT-X-','i')
  145. , itemsdpgza = tyad1026 + '(?<!0)(3)\\.\\1(?:((?<!0)\\d)\\2){2,}\\d+?,' + tyad1028 + '(?:' + tyad104 + tyad1028 + tyad1048 + tyad109
  146. , itemspdgza = '(?:' + tyad1015 + '[a-z\\d]{10,}0{2}\\d+?' + tyad1016 + '){5,}'
  147. , itemstygza = '(?<=(?:' + tyad1015 + tyad108 + tyad4 + hhzz + '+?){1,})' + tyad1014 + '(?:' + tyad1015 + '(?!' + tyad108 + tyad4 + ')' + tyada + '?){1,}' + tyad109
  148. , itemstygza1 = '(?<=' + tyad1020 + ')' + tyad1014 + tyad1052 + tyad1 + '3\\.3{3,}\\s*?,' + tyad1034 + '(?:' + tyad1052 + tyad1049 + tyad1034 + tyad109
  149. , itemstygza2 = new RegExp(tyad1032 + tyadb + '(\\\/' + bhhzz + '+?\\\/)[^\\\/]+?' + tyad1016 + '(?:' + tyadb + '\\2[^\\\/]+?' + tyad1016 + '){3,})' + tyad1014 + '#EXT-X-KEY\\s*?:\\s*?METHOD=NONE' + hhzz + '+?' + tyad1039 + tyad1016,'i')
  150. , itemstygza3 = new RegExp(tyad1039 + tyad6,'igm')
  151. , itemstygza4 = new RegExp(tyad1032 + '?:' + tyadb + '(?<!' + tyad105 + ')[a-z0-9\\\/]+?' + tyad6 + '?){3,}' + tyad1014 + '(?:' + tyad1039 + tyad6 + '){3,}','i')
  152. , itemstygza5 = new RegExp('(?<=(?<=' + hhzz + '+)' + tyad1014 + tyadi + tyad1018 + tyad1050 + tyad2 + '(?:' + hhzz + '+?' + tyad1045 + '1,}(?:' + tyadi + '3{5}' + tyad1050 + '{2,}' + tyad1047,'gi')
  153. , itemstygza6 = new RegExp('(?<=' + hhzz + '+)' + tyad1014 + '(?:#EXT-X-' + bhhzz + '+' + hhzz + '+){1,}(?=(?:' + tyad7 + '|' + tyad1 + '\\d))','gim')
  154. , itemstygza7 = new RegExp('(?<=' + tyad1052 + ')(?:#EXT-X-(?!(?:DISCONTINUITY|ENDLIST))' + tyad1017 + '){1,}(?=(?:' + tyad2 + '|#EXT-X-|' + tyad1 + '\\d))','gim')
  155. , itemstygza8 = new RegExp(tyad1014 + tyad1036 + tyad1 + '3\\.3{3,}\\s*?,' + tyad1035 + '(?:' + tyad1036 + tyad1049 + tyad1035 + '(?:' + tyad1036 + tyad1048 + tyad109,'gim')
  156. , itemstygpc1 = new RegExp(itemstygza1,'gim')
  157. , itemstygpc2 = new RegExp('(?:' + tyad1052 + '){7,}','gim')
  158. , itemstygpc3 = new RegExp('(?:' + tyad1052 + '){15,}','gim')
  159. , itemsPaichu = [/*动态排除指定资源 正规则表达式,以达到智能删除插播广告的效果*/
  160. new RegExp(tyad1031 + '(?![\\S\\s]*?(?:' + tyad1015 + '[a-z\\d]{10,}0{2}\\d+?' + tyad1016 + '){2,})[\\S\\s]*?' + tyad1014 + '(?:' + tyad1015 + '(?:[a-z]+?\\d+?|\\d+?[a-z]+?){10,}' + tyad1016 + '){2,}','i')]
  161. , itemsHandle = [{
  162. reUrl: wzm3u8,
  163. reAds: [new RegExp(itemsdpgza,'gim'), new RegExp(itemstygza,'gim'), itemstygpc1, itemstygza8, new RegExp('(?<=' + tyad1031 + '(?:#EXT-X-(?!KEY)' + tyad1017 + '){1,})(?:' + tyad1021 + tyad1017 + '(?:' + tyad1014 + ')?){1,}(?=' + tyad1021 + ')','gim'), /*动态拼接采集资源 正规则表达式,以达到智能删除插播广告的效果*/
  164. new RegExp(tyad1026 + '((?<!0)\\d\\.([1-9])(?!\\2)\\d{4,5}(?<!\\2)\\2),' + tyad1037 + '\\1,' + tyad1028 + '){2,6}' + tyad109,'gim'), new RegExp('(?<=' + tyad1030 + '+?(?:' + tyad1014 + tyad1048 + ')' + tyad1014 + '(?:' + tyad104 + hhzz + tyad1024 + '+?\\\/\\w{50,}\\.ts' + hhzz + '+?){1,}' + tyad1014 + '(?=' + tyad1030 + ')','gim'), new RegExp(tyadf + '(?:' + tyad100 + '?' + bhhzz + '+?' + tyad103 + '+?' + tyad1048 + ')' + tyad102 + '+?' + bhhzz + '+?-' + bhhzz + '+?\\d' + tyad1016 + '(?=' + tyad1 + ')','gim'), new RegExp(tyadf + bhhzz + '+?' + tyad103 + '+' + tyad1048 + ')(?:' + tyad1014 + ')?' + tyad102 + '+?[a-z\\d]+?0{4,}' + tyad1016 + '[\\s\\S]+?' + hhzz + '+[a-z\\d]+?0{2,}\\d' + tyad1016 + '(?<![\\s\\S]+?10' + tyad5 + '\\n*?[\\s\\S]*?' + hhzz + '+)(?=(?:' + tyad3 + '+|' + tyad1 + '\\d+(?:\\.\\d+)?\\s*?,' + hhzz + '+?[a-z\\d]+?10' + tyad1016 + '))','gi'), ],
  165. }]
  166. , itemsHandleby = [/*播放黑木耳采集资源的时候,额外增加该数组规则,避免其他的误杀*/
  167. {
  168. reUrl: /^https?:\/\/(?:[^\/]+?\.)?(?:hmr|heimuer)/i,
  169. reAds: [new RegExp('(\\n' + tyad2 + ')\\n.+\\n.+\\1','i'), new RegExp('(\\n' + tyad2 + ')(\\n.+\\n).+\\2.+\\2.+(\\2.+)?\\1','gi'), new RegExp('(?<=' + tyad1014 + ')' + tyad1039 + tyad5 + tyad1017 + tyad1047,'gim'), new RegExp(tyad1026 + '((?<!0)\\d\\.(?!0)\\d{4,5}[1-9]),' + tyad1037 + '\\1,' + tyad1028 + '){2,6}' + tyad109,'gim'), new RegExp(tyad1026 + '(\\d+?(?:\\.(?!0{1,},)\\d+?)?),' + tyad1037 + '\\1,' + tyad1028 + '){1,}' + tyad109,'gim'), ]
  170. }, /*播放华为采集资源的时候,额外增加该数组规则,避免其他资源误杀*/
  171. {
  172. reUrl: /^https?:\/\/(?:[^\/]+?\.)?nikanba/i,
  173. reAds: [new RegExp('(?<=' + tyad2 + ')' + hhzz + '+?' + tyad1 + '10,' + tyad1027 + tyada + '?' + tyad2 + '(?=' + hhzz + ')','gim'), new RegExp(tyad1014 + tyad1 + '2,' + tyad1040 + '3,' + tyad1040 + '1,' + tyad1029 + '(?:' + tyad104 + tyad1011 + tyad6 + '?' + tyad1048 + tyad3 + '+','gim'), ]
  174. }, ];
  175. const logysa = '%c[江小白-'
  176. , logysb = '-已经发现] ✂\n%c对比'
  177. , logysc = '-已经发现] ✂\n%c已经生效的广告正则:\n%c'
  178. , logysd = "的广告正则:\n%c"
  179. , logyse = '\n%c已经删除的广告内容:\n'
  180. , logysf = 'border-left:5px solid #A0B;color:#A0B;padding:3px'
  181. , logysg = 'color:#03A9F4;'
  182. , logysh = 'color:red;'
  183. , logysi = logysh
  184. , logysj = '广告标识'
  185. , logysk = '额外删除-具体内容] ✂%c'
  186. , logysl = '时间差异-具体内容] ✂\n%c'
  187. , logysm = '长度差异-具体内容] ✂\n%c'
  188. , logysn = '长短差异-具体内容] ✂\n%c'
  189. , logyso = '时间标识'
  190. , logysq = '名称差异-具体内容] ✂\n%c';
  191. /*以上是 M3U8 插播广告 过滤核心代码 不懂勿动*/
  192. const urlFromArg = arg=>typeof arg === 'string' ? arg : arg instanceof Request ? arg.url : String(arg);
  193. const isValidM3U8Url = url=>{
  194. return (wzm3u8.test(url) && m3u8wz.test(url) && !mp4wz.test(url) && !flvwz.test(url) && !tswz.test(url) && !playsharewz.test(url));
  195. }
  196. ;
  197. const matchM3u = url=>{
  198. try {
  199. if (isValidM3U8Url(url)) {
  200. spbfurl = url;
  201. const matchedItem = itemsHandle.find(item=>item.reUrl.test(url) && isValidM3U8Url(url) && !ggbmd.test(url));
  202. itemsHandleby.forEach(byItem=>byItem.reUrl.test(url) && isValidM3U8Url(url) && byItem.reAds.forEach(newReAd=>matchedItem.reAds.find(ad=>ad.source === newReAd.source && ad.flags === newReAd.flags) || matchedItem.reAds.push(newReAd)));
  203. return matchedItem;
  204. } else {
  205. return null;
  206. }
  207. } catch (e) {
  208. return null;
  209. }
  210. }
  211. ;
  212. const M3umatch = text=>{
  213. try {
  214. if (!text || !itemts.test(text) || !itemm3u8.test(text)) {
  215. return true;
  216. } else {
  217. return false;
  218. }
  219. } catch (e) {
  220. return false;
  221. }
  222. }
  223. ;
  224. const M3umatchu3M = (array,regExp)=>{
  225. return array.some(function(item) {
  226. return item.toString() === regExp.toString();
  227. });
  228. }
  229. ;
  230. const m3u8text = (text)=>{
  231. try {
  232. const regex = /^[a-z\d]{20,}/i;
  233. const lines = text.split('\n');
  234. let count = 0;
  235. for (let line of lines) {
  236. const trimmedLine = line.trim();
  237. if (itemts.test(trimmedLine)) {
  238. const match = trimmedLine.match(itemts);
  239. if (match) {
  240. const extension = match[0];
  241. const fileName = trimmedLine.slice(0, -extension.length);
  242. if (!regex.test(fileName)) {
  243. return false;
  244. }
  245. }
  246. }
  247. if (/0{2,}\d+$/.test(trimmedLine)) {
  248. count++;
  249. if (count >= 20) {
  250. return false;
  251. }
  252. }
  253. }
  254. return true;
  255. } catch (e) {
  256. return false;
  257. }
  258. }
  259. ;
  260. const endlist = (text)=>{
  261. try {
  262. if (!itemm3u8.test(text)) {
  263. return text;
  264. } else {
  265. if (ggljbmd.test(text)) {
  266. return text;
  267. } else {
  268. if (!new RegExp(tyad5,'i').test(text)) {
  269. return text;
  270. } else {
  271. const lines = text.trim().split('\n');
  272. const lastLine = lines[lines.length - 1];
  273. if (lastLine.trim() !== tyad7) {
  274. lines.push(tyad7);
  275. }
  276. return lines.join('\n');
  277. }
  278. }
  279. }
  280. } catch (e) {
  281. return text;
  282. }
  283. }
  284. ;
  285. const deleteAbnormalTs = (text,jxbgza,jxbgzb,jxbgzc,jxbgzd,jxbgze)=>{
  286. try {
  287. if (!shouldStopExecution) {
  288. if (text) {
  289. if (!itemm3u8.test(text)) {
  290. return text;
  291. } else {
  292. if (ggljbmd.test(text)) {
  293. shouldStopExecution = true;
  294. return text;
  295. } else {
  296. if (ggljdmb.test(text)) {
  297. if (new RegExp(tyad1023,'i').test(text)) {
  298. if (!new RegExp(tyad5 + '\\?','i').test(text)) {
  299. if (new RegExp(tyad5 + hhzz,'i').test(text)) {
  300. if (!jxbgzd) {
  301. jxbgzd = new RegExp('^\\s*?' + tyad8 + '\\s*?$','i');
  302. } else if (jxbgzd == '空') {
  303. jxbgzd = /^\s*?空\s*?$/;
  304. }
  305. try {
  306. const rgtya = tyad1015
  307. , rgtyb = jxbgza + tyad1016
  308. , regex = '(?<=' + rgtya + ')(' + jxbgzb + ')(?=' + rgtyb + ')'
  309. , regexx = new RegExp(regex,'gi')
  310. , tsPaths = text.match(new RegExp('(?:(?<=' + tyad1015 + '))?' + bhhzz + '+?(?=' + tyad1016 + ')','gi'))
  311. , matches = text.match(regexx)
  312. , paths = {};
  313. try {
  314. if (!jxbgze || jxbgze == '空' || (Number.isInteger(Number(jxbgze)) && tsPaths && tsPaths.length < jxbgze)) {
  315. if (matches && Array.isArray(matches)) {
  316. for (let i = 0; i < matches.length; i++) {
  317. const path = matches[i];
  318. if (!paths[path]) {
  319. paths[path] = [];
  320. }
  321. paths[path].push(path);
  322. }
  323. let maxCount = 0
  324. , maxPath = '';
  325. for (const path in paths) {
  326. if (paths[path].length > maxCount) {
  327. maxCount = paths[path].length;
  328. maxPath = path;
  329. }
  330. }
  331. if (maxCount > matches.length * 0.66 && Object.keys(paths).length < matches.length * 0.66) {
  332. let deleteCount = 0;
  333. for (const path in paths) {
  334. if (path !== maxPath) {
  335. deleteCount += paths[path].length;
  336. }
  337. }
  338. if (deleteCount <= maxCount) {
  339. for (const path in paths) {
  340. if (path !== maxPath) {
  341. paths[path].forEach(p=>{
  342. /*console.log("排除测试:\n"+p);*/
  343. if (!jxbgzd.test(p)) {
  344. text = text.replace(new RegExp(rgtya + p + rgtyb,'gi'), (match)=>{
  345. if (!dypd.test(打印开关)) {
  346. try {
  347. console.log(logysa + "广告资源" + logysb + jxbgzc + logysd + regexx + logyse + "%c" + match.replace(new RegExp(tyad1023,'gi'), tsLink=>{
  348. if (!tsLink.startsWith('http')) {
  349. if (m3u8gglj) {
  350. return new URL(tsLink,m3u8gglj).href;
  351. } else {
  352. return tsLink;
  353. }
  354. } else {
  355. return tsLink;
  356. }
  357. }
  358. ), logysf, logysg, logysh, logysg, logysi);
  359. } catch (e) {
  360. try {
  361. console.log(logysa + "广告资源" + logysb + jxbgzc + logysd + regexx + logyse + "%c" + match, logysf, logysg, logysh, logysg, logysi);
  362. } catch (e) {}
  363. }
  364. }
  365. return '';
  366. }
  367. );
  368. }
  369. }
  370. );
  371. }
  372. }
  373. } else {
  374. return text;
  375. }
  376. }
  377. } else {
  378. return text;
  379. }
  380. }
  381. } catch (e) {
  382. return text;
  383. }
  384. } catch (e) {
  385. return text;
  386. }
  387. }
  388. }
  389. }
  390. return endlist(text);
  391. } else {
  392. return text;
  393. }
  394. }
  395. }
  396. } else {
  397. return text;
  398. }
  399. } else {
  400. return text;
  401. }
  402. } catch (e) {
  403. return text;
  404. }
  405. }
  406. ;
  407. const durationtaragt = (text)=>{
  408. try {
  409. if (!itemm3u8.test(text)) {
  410. return text;
  411. } else {
  412. const lines = text.split('\n');
  413. const outputLines = [];
  414. let extinfCount = 0;
  415. let tsCount = 0;
  416. let lastExtinf = null;
  417. for (let i = 0; i < lines.length; i++) {
  418. const line = lines[i].trim();
  419. if (tyad12.test(line)) {
  420. const durationPart = line.split(',', 1)[0].replace(tyad12, '').trim();
  421. if (!isNaN(durationPart) && durationPart.trim() !== '') {
  422. extinfCount++;
  423. lastExtinf = line;
  424. } else {
  425. lastExtinf = null;
  426. }
  427. } else if (itemts.test(line)) {
  428. tsCount++;
  429. if (lastExtinf) {
  430. outputLines.push(lastExtinf);
  431. outputLines.push(line);
  432. lastExtinf = null;
  433. } else {
  434. outputLines.push(line);
  435. }
  436. } else if (line) {
  437. outputLines.push(line);
  438. }
  439. }
  440. if (extinfCount > tsCount) {
  441. const finalLines = [];
  442. let shouldKeepTs = false;
  443. for (let i = 0; i < outputLines.length; i++) {
  444. const line = outputLines[i];
  445. if (tyad12.test(line)) {
  446. shouldKeepTs = true;
  447. finalLines.push(line);
  448. } else if (itemts.test(line)) {
  449. if (shouldKeepTs) {
  450. finalLines.push(line);
  451. shouldKeepTs = false;
  452. }
  453. } else {
  454. finalLines.push(line);
  455. }
  456. }
  457. return finalLines.join('\n').trim();
  458. } else {
  459. return outputLines.join('\n').trim();
  460. }
  461. }
  462. } catch (e) {
  463. return text;
  464. }
  465. }
  466. ;
  467. const taragtduration = (text)=>{
  468. try {
  469. if (!itemm3u8.test(text)) {
  470. return text;
  471. } else {
  472. var lines = text.split('\n');
  473. var maxDuration = 0;
  474. var minDuration = Infinity;
  475. var targetDurationLineIndex = -1;
  476. var originalTargetDuration = 0;
  477. for (var i = 0; i < lines.length; i++) {
  478. if (lines[i].match(tyad12)) {
  479. var duration = parseFloat(lines[i].split(',')[0].split(':')[1]);
  480. if (duration > maxDuration) {
  481. maxDuration = duration;
  482. }
  483. if (duration < minDuration) {
  484. minDuration = duration;
  485. }
  486. } else if (lines[i].match(new RegExp('^\\s*?' + tyad9 + '\\s*?:','i'))) {
  487. targetDurationLineIndex = i;
  488. originalTargetDuration = parseInt(lines[i].split(':')[1], 10);
  489. }
  490. }
  491. if (targetDurationLineIndex === -1) {
  492. return text;
  493. } else {
  494. var newTargetDuration;
  495. if (maxDuration === minDuration) {
  496. var multiplier = maxDuration < 10 ? 1.5 : 1.23;
  497. newTargetDuration = Math.ceil(maxDuration * multiplier);
  498. } else {
  499. newTargetDuration = Math.ceil(maxDuration + minDuration);
  500. }
  501. if (newTargetDuration === originalTargetDuration) {
  502. var multiplier = maxDuration < 10 ? 1.5 : 1.23;
  503. newTargetDuration = Math.ceil(maxDuration * multiplier);
  504. }
  505. if (newTargetDuration === originalTargetDuration) {
  506. var multiplier = originalTargetDuration < 10 ? 1.5 : 1.23;
  507. newTargetDuration = Math.ceil(originalTargetDuration * multiplier);
  508. }
  509. if (newTargetDuration !== originalTargetDuration) {
  510. lines[targetDurationLineIndex] = tyad9 + ':' + newTargetDuration;
  511. try {
  512. if (!dypd.test(打印开关)) {
  513. console.log(logysa + logyso + "-已经发现] ✂" + '已经把《' + tyad9 + '》数值从原来的值<' + originalTargetDuration + '>修改成<' + newTargetDuration + '>', logysf);
  514. }
  515. } catch (e) {}
  516. return lines.join('\n');
  517. } else {
  518. return text;
  519. }
  520. }
  521. }
  522. } catch (e) {
  523. return text;
  524. }
  525. }
  526. ;
  527. const extinfa = (text)=>{
  528. try {
  529. if (!shouldStopExecution) {
  530. if (text) {
  531. if (!itemm3u8.test(text)) {
  532. return text;
  533. } else {
  534. if (ggljbmd.test(text)) {
  535. shouldStopExecution = true;
  536. return text;
  537. } else {
  538. if (!shouldStopExecution) {
  539. let lines = text.split('\n');
  540. let discontinuityIndices = [];
  541. let endListIndex = -1;
  542. let deletions = [];
  543. for (let i = 0; i < lines.length; i++) {
  544. if (lines[i].includes(tyad2)) {
  545. discontinuityIndices.push(i);
  546. } else if (lines[i].includes(tyad7)) {
  547. endListIndex = i;
  548. }
  549. }
  550. let indicesToDelete = new Set();
  551. for (let i = 0; i < discontinuityIndices.length; i++) {
  552. let startIndex = discontinuityIndices[i];
  553. let endIndex = -1;
  554. if (i < discontinuityIndices.length - 1) {
  555. endIndex = discontinuityIndices[i + 1];
  556. } else if (endListIndex !== -1) {
  557. endIndex = endListIndex;
  558. }
  559. if (endIndex !== -1) {
  560. let block = lines.slice(startIndex + 1, endIndex);
  561. let extinfLines = block.filter(line=>line.includes(tyad0));
  562. let tsLines = block.filter(line=>line.match(itemts));
  563. if (extinfLines.length >= 4 && extinfLines.length <= 6) {
  564. let totalExtinfValue = 0;
  565. for (let extinf of extinfLines) {
  566. const value = parseFloat(extinf.split(':')[1].split(',')[0]);
  567. totalExtinfValue += value;
  568. }
  569. if (totalExtinfValue <= 25 && (totalExtinfValue < 18 || totalExtinfValue >= 19)) {
  570. let threeDigitEndCount = 0;
  571. for (let extinf of extinfLines) {
  572. const value = extinf.split(':')[1].split(',')[0];
  573. if (value.match(tyad1055)) {
  574. threeDigitEndCount++;
  575. }
  576. }
  577. if (threeDigitEndCount >= 2) {
  578. deletions.push(lines.slice(startIndex + 1, endIndex).join('\n'));
  579. for (let j = startIndex + 1; j < endIndex; j++) {
  580. indicesToDelete.add(j);
  581. }
  582. }
  583. }
  584. }
  585. }
  586. }
  587. let filteredLines = [];
  588. for (let i = 0; i < lines.length; i++) {
  589. if (!indicesToDelete.has(i)) {
  590. filteredLines.push(lines[i]);
  591. }
  592. }
  593. try {
  594. if (!dypd.test(打印开关)) {
  595. if (deletions.length > 0) {
  596. console.log(logysa + logysl + deletions.reverse().map(line=>{
  597. return line.replace(tyad1053, tsLink=>{
  598. if (!tsLink.startsWith('http')) {
  599. if (m3u8gglj) {
  600. return new URL(tsLink,m3u8gglj).href;
  601. } else {
  602. return tsLink;
  603. }
  604. } else {
  605. return tsLink;
  606. }
  607. }
  608. );
  609. }
  610. ).join('\n'), logysf, logysi);
  611. }
  612. }
  613. } catch (e) {}
  614. return filteredLines.join('\n');
  615. } else {
  616. return text;
  617. }
  618. }
  619. }
  620. } else {
  621. return text;
  622. }
  623. } else {
  624. return text;
  625. }
  626. } catch (e) {
  627. return text;
  628. }
  629. }
  630. ;
  631. const extinfb = (text,exta,extb,extc,extd)=>{
  632. try {
  633. if (!shouldStopExecution) {
  634. if (text) {
  635. if (!itemm3u8.test(text)) {
  636. return text;
  637. } else {
  638. if (ggljbmd.test(text)) {
  639. shouldStopExecution = true;
  640. return text;
  641. } else {
  642. if (!shouldStopExecution) {
  643. let lines = text.split('\n');
  644. let discontinuityIndices = [];
  645. let endListIndex = -1;
  646. let deletedEntries = [];
  647. const tyad0Regex = new RegExp(tyad0);
  648. for (let i = 0; i < lines.length; i++) {
  649. const line = lines[i];
  650. if (line.includes(tyad2)) {
  651. discontinuityIndices.push(i);
  652. } else if (line.includes(tyad7)) {
  653. endListIndex = i;
  654. break;
  655. }
  656. }
  657. if (endListIndex === -1) {
  658. endListIndex = lines.length;
  659. }
  660. for (let i = 0; i < discontinuityIndices.length; i++) {
  661. const startIndex = discontinuityIndices[i];
  662. const endIndex = i < discontinuityIndices.length - 1 ? discontinuityIndices[i + 1] : endListIndex;
  663. if (endIndex <= startIndex) {
  664. continue;
  665. }
  666. let totalDuration = 0;
  667. let threeEndCount = 0;
  668. let blockValid = false;
  669. let extinfLinesCount = 0;
  670. for (let j = startIndex + 1; j < endIndex; j++) {
  671. const line = lines[j];
  672. if (!line) {
  673. continue;
  674. }
  675. if (tyad0Regex.test(line)) {
  676. extinfLinesCount++;
  677. const durationStr = line.split(':')[1]?.split(',')[0];
  678. const duration = parseFloat(durationStr) || 0;
  679. totalDuration += duration;
  680. if (exta.test(durationStr)) {
  681. threeEndCount++;
  682. }
  683. }
  684. }
  685. if (extinfLinesCount >= extb && extinfLinesCount <= extc && totalDuration <= extd && threeEndCount === 1) {
  686. blockValid = true;
  687. }
  688. if (blockValid) {
  689. for (let j = startIndex + 1; j < endIndex; j++) {
  690. if (lines[j]) {
  691. deletedEntries.push(lines[j]);
  692. lines[j] = null;
  693. }
  694. }
  695. }
  696. }
  697. let cleanedLines = lines.filter(line=>line !== null).join('\n');
  698. try {
  699. if (!dypd.test(打印开关)) {
  700. if (deletedEntries.length > 0) {
  701. console.log(logysa + logysl + deletedEntries.map(line=>{
  702. return line.replace(tyad1053, tsLink=>{
  703. if (!tsLink.startsWith('http')) {
  704. if (m3u8gglj) {
  705. return new URL(tsLink,m3u8gglj).href;
  706. } else {
  707. return tsLink;
  708. }
  709. } else {
  710. return tsLink;
  711. }
  712. }
  713. );
  714. }
  715. ).join('\n'), logysf, logysi);
  716. }
  717. }
  718. } catch (e) {}
  719. return cleanedLines;
  720. } else {
  721. return text;
  722. }
  723. }
  724. }
  725. } else {
  726. return text;
  727. }
  728. } else {
  729. return text;
  730. }
  731. } catch (e) {
  732. return text;
  733. }
  734. }
  735. ;
  736. const proqca = (text,item)=>{
  737. try {
  738. if (!shouldStopExecution) {
  739. if (text) {
  740. if (!itemm3u8.test(text)) {
  741. return text;
  742. } else {
  743. if (ggljbmd.test(text)) {
  744. shouldStopExecution = true;
  745. return text;
  746. } else {
  747. try {
  748. if ((!(new RegExp(itemsdpgza,'i').test(text) && ggljdmb.test(text))) && !new RegExp(tyad1014 + tyad1021,'i').test(text)) {
  749. gggzdp = true;
  750. } else {
  751. try {
  752. itemsHandle.forEach(item=>{
  753. item.reAds = item.reAds.filter(re=>re.source !== itemsdpgza);
  754. }
  755. );
  756. } catch (e) {}
  757. gggzdp = false;
  758. }
  759. } catch (e) {
  760. gggzdp = false;
  761. }
  762. if (ggljdmb.test(text) || !!gggzdp) {
  763. try {
  764. if (!gggzpd) {
  765. gggzpd = true;
  766. try {
  767. if (new RegExp(itemspdgza,'i').test(text) && new RegExp(itemstygza1,'i').test(text)) {
  768. itemsHandle.forEach(item=>{
  769. item.reAds = item.reAds.filter(re=>re.source !== itemstygza1);
  770. }
  771. );
  772. }
  773. } catch (e) {}
  774. try {
  775. if (!(new RegExp(itemspdgza,'i').test(text) && new RegExp(itemstygza,'i').test(text))) {
  776. itemsHandle.forEach(item=>{
  777. item.reAds = item.reAds.filter(re=>re.source !== itemstygza);
  778. }
  779. );
  780. }
  781. } catch (e) {}
  782. if (!dypd.test(打印开关)) {
  783. console.table(itemsPaichu);
  784. console.table(itemsHandle);
  785. }
  786. }
  787. } catch (e) {}
  788. try {
  789. if (itemsPaichu.some(regex=>regex.test(text))) {
  790. try {
  791. if (!M3umatchu3M(itemsHandle[0].reAds, itemstygza5)) {
  792. itemsHandle[0].reAds.push(itemstygza5);
  793. }
  794. } catch (e) {}
  795. text = extinfa(text);
  796. try {
  797. text = extinfb(text, tyad1055, 4, 6, 25);
  798. } catch (e) {}
  799. try {
  800. text = extinfb(text, tyad1056, 1, 2, 15);
  801. } catch (e) {}
  802. } else {
  803. if (new RegExp(tyadb + bhhzz + '+?' + tyad5 + '\\?' + tyad1017,'i').test(text)) {} else {
  804. if (m3u8text(text)) {
  805. text = extinfa(text);
  806. try {
  807. text = extinfb(text, tyad1055, 4, 6, 25);
  808. } catch (e) {}
  809. try {
  810. text = extinfb(text, tyad1056, 1, 2, 15);
  811. } catch (e) {}
  812. } else {
  813. try {
  814. if (text.match(itemstygza2)) {
  815. const matchessc = text.match(itemstygza3);
  816. if (matchessc) {
  817. try {
  818. if (!dypd.test(打印开关)) {
  819. console.log(logysa + "资源广告" + logysc + itemstygza3 + logyse, logysf, logysg, logysh, logysg);
  820. matchessc.forEach(match=>{
  821. console.log(match);
  822. }
  823. );
  824. }
  825. } catch (e) {}
  826. text = text.replace(itemstygza3, '');
  827. } else {
  828. text = deleteAbnormalTs(text, '[^\\.]+?', '(?:' + bhhzz + '+\\\/|\\b)', '路径');
  829. }
  830. } else {
  831. text = deleteAbnormalTs(text, '[^\\.]+?', '(?:' + bhhzz + '+\\\/|\\b)', '路径');
  832. }
  833. } catch (e) {}
  834. try {
  835. if (!text.match(itemstygza4)) {
  836. text = deleteAbnormalTs(text, '(?:\\d+?|[a-z]+?)', '\\w+?(?:[^\\d]\\d{2})?', '名称');
  837. }
  838. } catch (e) {}
  839. try {
  840. text = deleteAbnormalTs(text, '\\d+?', '\\w+(?=\\d{3})', '名称', '空', 100);
  841. } catch (e) {}
  842. try {
  843. text = deleteAbnormalTs(text, '\\d+?', '\\w+(?=\\d{4})', '名称', '空');
  844. } catch (e) {}
  845. try {
  846. text = deleteAbnormalTs(text, '\\d+?', '[^0]\\d+[^0]0{2,}\\d0', '名称', /(?<=[^0]0{3,})\d+$/);
  847. } catch (e) {}
  848. }
  849. }
  850. }
  851. } catch (e) {}
  852. try {
  853. for (const reAd of item.reAds) {
  854. try {
  855. text = text.replace(reAd, function(match) {
  856. try {
  857. if (((reAd === itemstygpc1 || reAd === itemstygza5 || reAd === itemstygza8) && match.match(itemstygpc2)) || match.match(itemstygpc3)) {
  858. return match;
  859. } else {
  860. try {
  861. if (!dypd.test(打印开关)) {
  862. try {
  863. console.log(logysa + "资源广告" + logysc + reAd + logyse + "%c" + match.replace(new RegExp(tyad1023,'gi'), tsLink=>{
  864. if (!tsLink.startsWith('http')) {
  865. if (m3u8gglj) {
  866. return new URL(tsLink,m3u8gglj).href;
  867. } else {
  868. return tsLink;
  869. }
  870. } else {
  871. return tsLink;
  872. }
  873. }
  874. ), logysf, logysg, logysh, logysg, logysi);
  875. } catch (e) {
  876. try {
  877. console.log(logysa + "资源广告" + logysc + reAd + logyse + "%c" + match, logysf, logysg, logysh, logysg, logysi);
  878. } catch (e) {}
  879. }
  880. }
  881. } catch (e) {}
  882. return "";
  883. }
  884. } catch (e) {
  885. return match;
  886. }
  887. });
  888. } catch (e) {
  889. continue;
  890. }
  891. }
  892. } catch (e) {}
  893. if (text.length < text.length) {
  894. return endlist(text);
  895. } else {
  896. return text;
  897. }
  898. } else {
  899. return text;
  900. }
  901. }
  902. }
  903. } else {
  904. return text;
  905. }
  906. } else {
  907. return text;
  908. }
  909. } catch (e) {
  910. return text;
  911. }
  912. }
  913. ;
  914. const proqcb = (text)=>{
  915. try {
  916. if (!shouldStopExecution) {
  917. if (text) {
  918. if (!itemm3u8.test(text)) {
  919. return text;
  920. } else {
  921. if (ggljbmd.test(text)) {
  922. shouldStopExecution = true;
  923. return text;
  924. } else {
  925. if (!shouldStopExecution) {
  926. const lines = text.split('\n');
  927. const tsLines = lines.filter(line=>line.trim().match(tyad5));
  928. const tsLinesWith00 = tsLines.filter(line=>line.includes('00'));
  929. const totalTsLines = tsLines.length;
  930. const tsLinesWith00Count = tsLinesWith00.length;
  931. if (tsLinesWith00Count / totalTsLines >= 0.666) {
  932. const prefixes = tsLinesWith00.map(line=>{
  933. const index = line.indexOf('00');
  934. return line.substring(0, index + 2);
  935. }
  936. );
  937. let commonPrefix = prefixes[0];
  938. const backupArray = [];
  939. for (let i = 1; i < prefixes.length; i++) {
  940. let currentPrefix = '';
  941. for (let j = 0; j < Math.min(commonPrefix.length, prefixes[i].length); j++) {
  942. if (commonPrefix[j] === prefixes[i][j]) {
  943. currentPrefix += commonPrefix[j];
  944. backupArray.push(currentPrefix);
  945. } else {
  946. break;
  947. }
  948. }
  949. commonPrefix = currentPrefix;
  950. if (commonPrefix === '') {
  951. break;
  952. }
  953. }
  954. const uniqueBackupArray = Array.from(new Set(backupArray));
  955. let longestItem = '';
  956. for (const item of uniqueBackupArray) {
  957. if (item.length > longestItem.length) {
  958. longestItem = item;
  959. }
  960. }
  961. const tsLinesToDelete = tsLines.filter(line=>!line.startsWith(longestItem));
  962. const tsLinesToDeleteCount = tsLinesToDelete.length;
  963. if (tsLinesToDeleteCount / totalTsLines > 0.666) {
  964. return text;
  965. } else {
  966. const deletedLines = [];
  967. const newLines = [];
  968. let i = 0;
  969. while (i < lines.length) {
  970. if (lines[i].includes(tyad0) && i + 1 < lines.length && lines[i + 1].trim().match(tyad5)) {
  971. const tsLine = lines[i + 1];
  972. const fileName = tsLine.split('/').pop();
  973. if (tyad14.test(fileName)) {
  974. newLines.push(lines[i], lines[i + 1]);
  975. i += 2;
  976. } else if (!tsLine.startsWith(longestItem)) {
  977. deletedLines.push(lines[i], lines[i + 1]);
  978. i += 2;
  979. } else {
  980. newLines.push(lines[i], lines[i + 1]);
  981. i += 2;
  982. }
  983. } else {
  984. newLines.push(lines[i]);
  985. i += 1;
  986. }
  987. }
  988. try {
  989. if (!dypd.test(打印开关)) {
  990. if (deletedLines.length > 0) {
  991. try {
  992. console.log(logysa + logysq + deletedLines.reverse().map(line=>{
  993. return line.replace(tyad1053, tsLink=>{
  994. if (!tsLink.startsWith('http')) {
  995. if (m3u8gglj) {
  996. return new URL(tsLink,m3u8gglj).href;
  997. } else {
  998. return tsLink;
  999. }
  1000. } else {
  1001. return tsLink;
  1002. }
  1003. }
  1004. );
  1005. }
  1006. ).join('\n'), logysf, logysi);
  1007. } catch (e) {}
  1008. }
  1009. }
  1010. } catch (e) {}
  1011. return endlist(newLines.join('\n'));
  1012. }
  1013. } else {
  1014. return text;
  1015. }
  1016. } else {
  1017. return text;
  1018. }
  1019. }
  1020. }
  1021. } else {
  1022. return text;
  1023. }
  1024. } else {
  1025. return text;
  1026. }
  1027. } catch (e) {
  1028. return text;
  1029. }
  1030. }
  1031. ;
  1032. const proqcc = (text)=>{
  1033. try {
  1034. if (!shouldStopExecution) {
  1035. if (text) {
  1036. if (!itemm3u8.test(text)) {
  1037. return text;
  1038. } else {
  1039. if (ggljbmd.test(text)) {
  1040. shouldStopExecution = true;
  1041. return text;
  1042. } else {
  1043. if (!shouldStopExecution) {
  1044. let tsFileNameLength = 0;
  1045. let tsFileNameLengthTolerance = 1;
  1046. let firstExtInfRow = '';
  1047. let extInfJudgeRowCounter = 0;
  1048. let sameExtInfNameCounter = 0;
  1049. let extInfBenchmarkCounter = 5;
  1050. let previousTsNameIndex = -1;
  1051. let firstTsNameIndex = -1;
  1052. let tsType = 0;
  1053. let extXMode = 0;
  1054. let violentFilterModeFlag = false;
  1055. let result = [];
  1056. let deletedLines = [];
  1057. const numberBeforeTsRegex = new RegExp('(\\d+)' + tyad5,'i');
  1058. const tsExtensionRegex = new RegExp(tyad5,'i');
  1059. const lines = text.split('\n');
  1060. function extractNumberBeforeTs(str) {
  1061. const match = numberBeforeTsRegex.exec(str);
  1062. if (match) {
  1063. return parseInt(match[1], 10);
  1064. }
  1065. return null;
  1066. }
  1067. ;function getTsIndex(str) {
  1068. const match = tsExtensionRegex.exec(str);
  1069. if (match) {
  1070. return match.index;
  1071. }
  1072. return -1;
  1073. }
  1074. ;if (violentFilterModeFlag) {
  1075. tsType = 2;
  1076. } else {
  1077. let normalIntTsCounter = 0;
  1078. let diffIntTsCounter = 0;
  1079. let lastTsNameLength = 0;
  1080. for (let i = 0; i < lines.length; i++) {
  1081. const line = lines[i];
  1082. if (extInfJudgeRowCounter === 0 && line.startsWith(tyad0)) {
  1083. firstExtInfRow = line;
  1084. extInfJudgeRowCounter++;
  1085. } else if (extInfJudgeRowCounter === 1 && line.startsWith(tyad0)) {
  1086. if (line !== firstExtInfRow) {
  1087. firstExtInfRow = '';
  1088. }
  1089. extInfJudgeRowCounter++;
  1090. }
  1091. let currentTsNameLength = getTsIndex(line);
  1092. if (currentTsNameLength > 0) {
  1093. if (extInfJudgeRowCounter === 1) {
  1094. tsFileNameLength = currentTsNameLength;
  1095. }
  1096. lastTsNameLength = currentTsNameLength;
  1097. let tsNameIndex = extractNumberBeforeTs(line);
  1098. if (tsNameIndex === null) {
  1099. if (extInfJudgeRowCounter === 1) {
  1100. tsType = 1;
  1101. } else if (extInfJudgeRowCounter === 2 && (tsType === 1 || currentTsNameLength === tsFileNameLength)) {
  1102. tsType = 1;
  1103. break;
  1104. } else {
  1105. diffIntTsCounter++;
  1106. }
  1107. } else {
  1108. if (normalIntTsCounter === 0) {
  1109. previousTsNameIndex = tsNameIndex;
  1110. firstTsNameIndex = tsNameIndex;
  1111. previousTsNameIndex = firstTsNameIndex - 1;
  1112. }
  1113. if (currentTsNameLength !== tsFileNameLength) {
  1114. if (currentTsNameLength === lastTsNameLength + 1 && tsNameIndex === previousTsNameIndex + 1) {
  1115. if (diffIntTsCounter) {
  1116. if (tsNameIndex === previousTsNameIndex + 1) {
  1117. tsType = 0;
  1118. previousTsNameIndex = firstTsNameIndex - 1;
  1119. break;
  1120. } else {
  1121. tsType = 2;
  1122. break;
  1123. }
  1124. }
  1125. normalIntTsCounter++;
  1126. previousTsNameIndex = tsNameIndex;
  1127. } else {
  1128. diffIntTsCounter++;
  1129. }
  1130. } else {
  1131. if (diffIntTsCounter) {
  1132. if (tsNameIndex === previousTsNameIndex + 1) {
  1133. tsType = 0;
  1134. previousTsNameIndex = firstTsNameIndex - 1;
  1135. break;
  1136. } else {
  1137. tsType = 2;
  1138. break;
  1139. }
  1140. }
  1141. normalIntTsCounter++;
  1142. previousTsNameIndex = tsNameIndex;
  1143. }
  1144. }
  1145. }
  1146. if (i === lines.length - 1) {
  1147. tsType = 2;
  1148. }
  1149. }
  1150. }
  1151. for (let i = 0; i < lines.length; i++) {
  1152. const line = lines[i];
  1153. if (tsType === 0) {
  1154. if (line.startsWith(tyad2) && lines[i + 1] && lines[i + 2]) {
  1155. if (i > 0 && lines[i - 1].startsWith('#EXT-X-')) {
  1156. result.push(line);
  1157. continue;
  1158. } else {
  1159. let currentTsNameLength = getTsIndex(lines[i + 2]);
  1160. if (currentTsNameLength > 0) {
  1161. if (currentTsNameLength - tsFileNameLength > tsFileNameLengthTolerance) {
  1162. if (lines[i + 3] && lines[i + 3].startsWith(tyad2)) {
  1163. deletedLines.push(lines[i], lines[i + 1], lines[i + 2], lines[i + 3]);
  1164. i += 3;
  1165. } else {
  1166. deletedLines.push(lines[i], lines[i + 1], lines[i + 2]);
  1167. i += 2;
  1168. }
  1169. continue;
  1170. } else {
  1171. tsFileNameLength = currentTsNameLength;
  1172. }
  1173. let currentTsNameIndex = extractNumberBeforeTs(lines[i + 2]);
  1174. if (currentTsNameIndex !== previousTsNameIndex + 1) {
  1175. if (lines[i + 3] && lines[i + 3].startsWith(tyad2)) {
  1176. deletedLines.push(lines[i], lines[i + 1], lines[i + 2], lines[i + 3]);
  1177. i += 3;
  1178. } else {
  1179. deletedLines.push(lines[i], lines[i + 1], lines[i + 2]);
  1180. i += 2;
  1181. }
  1182. continue;
  1183. }
  1184. }
  1185. }
  1186. }
  1187. if (line.startsWith(tyad0) && lines[i + 1]) {
  1188. let currentTsNameLength = getTsIndex(lines[i + 1]);
  1189. if (currentTsNameLength > 0) {
  1190. if (currentTsNameLength - tsFileNameLength > tsFileNameLengthTolerance) {
  1191. if (lines[i + 2] && lines[i + 2].startsWith(tyad2)) {
  1192. deletedLines.push(lines[i], lines[i + 1], lines[i + 2]);
  1193. i += 2;
  1194. } else {
  1195. deletedLines.push(lines[i], lines[i + 1]);
  1196. i += 1;
  1197. }
  1198. continue;
  1199. } else {
  1200. tsFileNameLength = currentTsNameLength;
  1201. }
  1202. let currentTsNameIndex = extractNumberBeforeTs(lines[i + 1]);
  1203. if (currentTsNameIndex === previousTsNameIndex + 1) {
  1204. previousTsNameIndex++;
  1205. } else {
  1206. if (lines[i + 2].startsWith(tyad2)) {
  1207. deletedLines.push(lines[i], lines[i + 1], lines[i + 2]);
  1208. i += 2;
  1209. } else {
  1210. deletedLines.push(lines[i], lines[i + 1]);
  1211. i += 1;
  1212. }
  1213. continue;
  1214. }
  1215. }
  1216. }
  1217. } else if (tsType === 1) {
  1218. if (line.startsWith(tyad0)) {
  1219. if (line === firstExtInfRow && sameExtInfNameCounter <= extInfBenchmarkCounter && extXMode === 0) {
  1220. sameExtInfNameCounter++;
  1221. } else {
  1222. extXMode = 1;
  1223. }
  1224. if (sameExtInfNameCounter > extInfBenchmarkCounter) {
  1225. extXMode = 1;
  1226. }
  1227. }
  1228. if (line.startsWith(tyad2)) {
  1229. if (i > 0 && lines[i - 1].startsWith(tyad15)) {
  1230. result.push(line);
  1231. continue;
  1232. } else {
  1233. if (lines[i + 1] && lines[i + 1].startsWith(tyad0) && lines[i + 2] && getTsIndex(lines[i + 2]) > 0) {
  1234. let extXDiscontinuityConditionFlag = false;
  1235. if (extXMode === 1) {
  1236. extXDiscontinuityConditionFlag = lines[i + 1] !== firstExtInfRow && sameExtInfNameCounter > extInfBenchmarkCounter;
  1237. }
  1238. if (lines[i + 3] && lines[i + 3].startsWith(tyad2) && extXDiscontinuityConditionFlag) {
  1239. deletedLines.push(lines[i], lines[i + 1], lines[i + 2], lines[i + 3]);
  1240. i += 3;
  1241. }
  1242. continue;
  1243. }
  1244. }
  1245. }
  1246. } else {
  1247. if (line.startsWith(tyad2)) {
  1248. if (i > 0 && lines[i - 1].startsWith(tyad15)) {
  1249. result.push(line);
  1250. continue;
  1251. } else {
  1252. continue;
  1253. }
  1254. }
  1255. }
  1256. result.push(line);
  1257. }
  1258. try {
  1259. if (!dypd.test(打印开关)) {
  1260. if (deletedLines.length > 0) {
  1261. try {
  1262. console.log(logysa + logysq + deletedLines.reverse().map(line=>{
  1263. return line.replace(tyad1053, tsLink=>{
  1264. if (!tsLink.startsWith('http')) {
  1265. if (m3u8gglj) {
  1266. return new URL(tsLink,m3u8gglj).href;
  1267. } else {
  1268. return tsLink;
  1269. }
  1270. } else {
  1271. return tsLink;
  1272. }
  1273. }
  1274. );
  1275. }
  1276. ).join('\n'), logysf, logysi);
  1277. } catch (e) {}
  1278. }
  1279. }
  1280. } catch (e) {}
  1281. return endlist(result.join('\n'));
  1282. } else {
  1283. return text;
  1284. }
  1285. }
  1286. }
  1287. } else {
  1288. return text;
  1289. }
  1290. } else {
  1291. return text;
  1292. }
  1293. } catch (e) {
  1294. return text;
  1295. }
  1296. }
  1297. ;
  1298. const removeprunerm3u8a = (text)=>{
  1299. try {
  1300. if (!shouldStopExecution) {
  1301. if (text) {
  1302. if (!itemm3u8.test(text)) {
  1303. return text;
  1304. } else {
  1305. if (ggljbmd.test(text)) {
  1306. shouldStopExecution = true;
  1307. return text;
  1308. } else {
  1309. let deletedContent = '';
  1310. text = text.replace(itemstygza6, (match)=>{
  1311. deletedContent += match + '\n';
  1312. return '';
  1313. }
  1314. );
  1315. try {
  1316. if (deletedContent.trim() !== '') {
  1317. if (!dypd.test(打印开关)) {
  1318. console.log(logysa + logysk + deletedContent, logysf, logysi);
  1319. }
  1320. }
  1321. } catch (e) {}
  1322. return endlist(text);
  1323. }
  1324. }
  1325. } else {
  1326. return text;
  1327. }
  1328. } else {
  1329. return text;
  1330. }
  1331. } catch (e) {
  1332. return text;
  1333. }
  1334. }
  1335. ;
  1336. const removeprunerm3u8b = (text)=>{
  1337. try {
  1338. if (!shouldStopExecution) {
  1339. if (text) {
  1340. if (!itemm3u8.test(text)) {
  1341. return text;
  1342. } else {
  1343. if (ggljbmd.test(text)) {
  1344. shouldStopExecution = true;
  1345. return text;
  1346. } else {
  1347. let deletedContent = '';
  1348. let addedMatches = new Set();
  1349. text = text.replace(itemstygza7, (match)=>{
  1350. match = match.trim();
  1351. if (!addedMatches.has(match) && match !== '') {
  1352. deletedContent += match + '\n';
  1353. addedMatches.add(match);
  1354. }
  1355. return '';
  1356. }
  1357. );
  1358. try {
  1359. if (deletedContent.trim() !== '') {
  1360. if (!dypd.test(打印开关)) {
  1361. console.log(logysa + logysk + deletedContent, logysf, logysi);
  1362. }
  1363. }
  1364. } catch (e) {}
  1365. return endlist(text);
  1366. }
  1367. }
  1368. } else {
  1369. return text;
  1370. }
  1371. } else {
  1372. return text;
  1373. }
  1374. } catch (e) {
  1375. return text;
  1376. }
  1377. }
  1378. ;
  1379. const removeprunerm3u8c = (text)=>{
  1380. try {
  1381. if (!shouldStopExecution) {
  1382. if (text) {
  1383. if (!itemm3u8.test(text)) {
  1384. return text;
  1385. } else {
  1386. if (ggljbmd.test(text)) {
  1387. shouldStopExecution = true;
  1388. return text;
  1389. } else {
  1390. const lines = text.split('\n');
  1391. const extinfLines = lines.filter(line=>tyad11.test(line));
  1392. const extinfValues = extinfLines.map(line=>parseFloat(line.split(':')[1].split(',')[0]));
  1393. const valueCounts = extinfValues.reduce((acc,value)=>{
  1394. acc[value] = (acc[value] || 0) + 1;
  1395. return acc;
  1396. }
  1397. , {});
  1398. const maxCount = Math.max(...Object.values(valueCounts));
  1399. const maxValue = Object.keys(valueCounts).find(key=>valueCounts[key] === maxCount);
  1400. const maxValueRatio = maxCount / extinfValues.length;
  1401. let deletedLines = [];
  1402. if (maxValueRatio > 0.987) {
  1403. const newLines = [];
  1404. let skipNextTs = false;
  1405. for (let i = 0; i < lines.length; i++) {
  1406. if (tyad11.test(lines[i])) {
  1407. if (firstExtinf) {
  1408. firstExtinf = false;
  1409. newLines.push(lines[i]);
  1410. skipNextTs = false;
  1411. } else if (i === lines.length - 1 || !tyad11.test(lines[i + 1])) {
  1412. lastExtinf = true;
  1413. newLines.push(lines[i]);
  1414. skipNextTs = false;
  1415. } else {
  1416. const value = parseFloat(lines[i].split(':')[1].split(',')[0]);
  1417. if (value != maxValue) {
  1418. deletedLines.push(lines[i], lines[i + 1]);
  1419. skipNextTs = true;
  1420. } else {
  1421. newLines.push(lines[i]);
  1422. skipNextTs = false;
  1423. }
  1424. }
  1425. } else if (skipNextTs) {
  1426. skipNextTs = false;
  1427. } else {
  1428. newLines.push(lines[i]);
  1429. }
  1430. }
  1431. if (deleteCount > maxValueRatio * extinfValues.length) {
  1432. return text;
  1433. } else {
  1434. text = endlist(newLines.join('\n'));
  1435. }
  1436. }
  1437. try {
  1438. if (deletedLines.length > 0) {
  1439. if (!dypd.test(打印开关)) {
  1440. console.log(logysa + logysl + deletedLines.map(line=>{
  1441. return line.replace(tyad1053, tsLink=>{
  1442. if (!tsLink.startsWith('http')) {
  1443. if (m3u8gglj) {
  1444. return new URL(tsLink,m3u8gglj).href;
  1445. } else {
  1446. return tsLink;
  1447. }
  1448. } else {
  1449. return tsLink;
  1450. }
  1451. }
  1452. );
  1453. }
  1454. ).join('\n'), logysf, logysi);
  1455. }
  1456. }
  1457. } catch (e) {}
  1458. return text;
  1459. }
  1460. }
  1461. } else {
  1462. return text;
  1463. }
  1464. } else {
  1465. return text;
  1466. }
  1467. } catch (e) {
  1468. return text;
  1469. }
  1470. }
  1471. ;
  1472. const removeprunerm3u8d = (text)=>{
  1473. try {
  1474. if (!shouldStopExecution) {
  1475. if (text) {
  1476. if (!itemm3u8.test(text)) {
  1477. return text;
  1478. } else {
  1479. if (ggljbmd.test(text)) {
  1480. shouldStopExecution = true;
  1481. return text;
  1482. } else {
  1483. const lines = text.split('\n');
  1484. const urlLengths = [];
  1485. const urlsWithIndex = [];
  1486. lines.forEach((line,index)=>{
  1487. const match = line.match(new RegExp(tyad5 + '\\s*?$','i'));
  1488. if (match) {
  1489. urlsWithIndex.push({
  1490. url: line,
  1491. index
  1492. });
  1493. urlLengths.push(line.length);
  1494. }
  1495. }
  1496. );
  1497. const lengthCounts = urlLengths.reduce((acc,length)=>{
  1498. acc[length] = (acc[length] || 0) + 1;
  1499. return acc;
  1500. }
  1501. , {});
  1502. const total = urlLengths.length;
  1503. let dominantLength = null;
  1504. for (const length in lengthCounts) {
  1505. if (lengthCounts[length] / total >= 0.789) {
  1506. dominantLength = parseInt(length);
  1507. break;
  1508. }
  1509. }
  1510. let deletedUrls = [];
  1511. if (dominantLength !== null) {
  1512. urlsWithIndex.forEach(({url, index})=>{
  1513. if (url.length !== dominantLength && !tyad14.test(url)) {
  1514. deletedUrls.push(url);
  1515. }
  1516. }
  1517. );
  1518. if (deletedUrls.length > lengthCounts[dominantLength]) {
  1519. return text;
  1520. } else {
  1521. deletedUrls.forEach((url)=>{
  1522. const {index} = urlsWithIndex.find(u=>u.url === url);
  1523. if (index >= 0) {
  1524. lines.splice(index, 1);
  1525. if (index - 1 >= 0 && !new RegExp(tyad7,'i').test(lines[index - 1])) {
  1526. lines.splice(index - 1, 1);
  1527. }
  1528. }
  1529. }
  1530. );
  1531. }
  1532. }
  1533. if (deletedUrls.length > 0) {
  1534. if (!dypd.test(打印开关)) {
  1535. console.log(logysa + logysm + deletedUrls.map(line=>{
  1536. return line.replace(tyad1053, tsLink=>{
  1537. if (!tsLink.startsWith('http')) {
  1538. if (m3u8gglj) {
  1539. return new URL(tsLink,m3u8gglj).href;
  1540. } else {
  1541. return tsLink;
  1542. }
  1543. } else {
  1544. return tsLink;
  1545. }
  1546. }
  1547. );
  1548. }
  1549. ).join('\n'), logysf, logysi);
  1550. }
  1551. }
  1552. return endlist(lines.join('\n'));
  1553. }
  1554. }
  1555. } else {
  1556. return text;
  1557. }
  1558. } else {
  1559. return text;
  1560. }
  1561. } catch (e) {
  1562. return text
  1563. }
  1564. }
  1565. ;
  1566. const removeprunerm3u8e = (text)=>{
  1567. try {
  1568. if (!shouldStopExecution) {
  1569. if (text) {
  1570. if (!itemm3u8.test(text)) {
  1571. return text;
  1572. } else {
  1573. if (ggljbmd.test(text)) {
  1574. shouldStopExecution = true;
  1575. return text;
  1576. } else {
  1577. const lines = text.split('\n');
  1578. const matchedLines = [];
  1579. const allLines = lines.map((line,index)=>({
  1580. line,
  1581. index
  1582. }));
  1583. allLines.forEach(item=>{
  1584. const match = item.line.match(tyad107);
  1585. if (match) {
  1586. matchedLines.push({
  1587. ...item,
  1588. matchedGroup: match[1]
  1589. });
  1590. }
  1591. }
  1592. );
  1593. if (matchedLines.length === 0) {
  1594. return text;
  1595. } else {
  1596. const matchedGroupCounts = {};
  1597. matchedLines.forEach(item=>{
  1598. matchedGroupCounts[item.matchedGroup] = (matchedGroupCounts[item.matchedGroup] || 0) + 1;
  1599. }
  1600. );
  1601. const minCount = Math.min(...Object.values(matchedGroupCounts));
  1602. const lessFrequentMatchedGroups = Object.keys(matchedGroupCounts).filter(group=>matchedGroupCounts[group] === minCount);
  1603. let filteredMatchedGroups = lessFrequentMatchedGroups.map(group=>{
  1604. const lastSlashIndex = group.lastIndexOf('/');
  1605. if (lastSlashIndex !== -1) {
  1606. group = group.substring(0, lastSlashIndex + 1);
  1607. }
  1608. if (!group.match(/^https?:\/\//) && !group.startsWith('/')) {
  1609. return null;
  1610. }
  1611. return group;
  1612. }
  1613. ).filter(group=>group !== null);
  1614. const totalMatched = matchedLines.length;
  1615. let dominantMatchedGroup;
  1616. for (const matchedGroup in matchedGroupCounts) {
  1617. if (matchedGroupCounts[matchedGroup] / totalMatched > 0.66) {
  1618. dominantMatchedGroup = matchedGroup;
  1619. break;
  1620. }
  1621. }
  1622. if (!dominantMatchedGroup) {
  1623. return text;
  1624. } else {
  1625. let diffCount = 0;
  1626. for (let i = allLines.length - 1; i >= 0; i--) {
  1627. if (allLines[i].line.startsWith(tyad0)) {
  1628. const nextLineIndex = i + 1;
  1629. let nextLine;
  1630. if (nextLineIndex < allLines.length) {
  1631. nextLine = allLines[nextLineIndex].line;
  1632. } else {
  1633. nextLine = undefined;
  1634. }
  1635. let match;
  1636. if (nextLine) {
  1637. match = nextLine.match(tyad107);
  1638. } else {
  1639. match = undefined;
  1640. }
  1641. if (!match || match[1] !== dominantMatchedGroup) {
  1642. diffCount++;
  1643. }
  1644. }
  1645. }
  1646. if (diffCount / totalMatched > 0.66) {
  1647. return text;
  1648. } else {
  1649. const deletedLines = [];
  1650. if (filteredMatchedGroups.length > 0) {
  1651. for (let i = allLines.length - 1; i >= 0; i--) {
  1652. if (allLines[i].line.startsWith(tyad0)) {
  1653. const nextLineIndex = i + 1;
  1654. let nextLine;
  1655. if (nextLineIndex < allLines.length) {
  1656. nextLine = allLines[nextLineIndex].line;
  1657. } else {
  1658. nextLine = undefined;
  1659. }
  1660. const cleanedNextLine = nextLine ? nextLine.replace(new RegExp(tyad5 + '.*?$','i'), '') : '';
  1661. if (!tyad10.test(cleanedNextLine)) {
  1662. const isFilteredMatched = filteredMatchedGroups.some(group=>nextLine && nextLine.startsWith(group));
  1663. if (isFilteredMatched) {
  1664. deletedLines.push(nextLine);
  1665. deletedLines.push(allLines[i].line);
  1666. allLines.splice(i, 2);
  1667. }
  1668. }
  1669. }
  1670. }
  1671. } else {
  1672. for (let i = allLines.length - 1; i >= 0; i--) {
  1673. if (allLines[i].line.startsWith(tyad0)) {
  1674. const nextLineIndex = i + 1;
  1675. let nextLine;
  1676. if (nextLineIndex < allLines.length) {
  1677. nextLine = allLines[nextLineIndex].line;
  1678. } else {
  1679. nextLine = undefined;
  1680. }
  1681. const cleanedNextLine = nextLine ? nextLine.replace(new RegExp(tyad5 + '.*?$','i'), '') : '';
  1682. let match;
  1683. if (nextLine) {
  1684. match = nextLine.match(tyad107);
  1685. } else {
  1686. match = undefined;
  1687. }
  1688. if (!match || match[1] !== dominantMatchedGroup) {
  1689. if (!tyad10.test(cleanedNextLine)) {
  1690. deletedLines.push(nextLine);
  1691. deletedLines.push(allLines[i].line);
  1692. allLines.splice(i, 2);
  1693. }
  1694. }
  1695. }
  1696. }
  1697. }
  1698. const tsToDeleteCount = deletedLines.length / 2;
  1699. if (tsToDeleteCount > totalMatched) {
  1700. return text;
  1701. } else {
  1702. try {
  1703. if (deletedLines.length > 0) {
  1704. try {
  1705. if (!dypd.test(打印开关)) {
  1706. console.log(logysa + logysn + deletedLines.reverse().map(line=>{
  1707. return line.replace(tyad1053, tsLink=>{
  1708. if (!tsLink.startsWith('http')) {
  1709. if (m3u8gglj) {
  1710. return new URL(tsLink,m3u8gglj).href;
  1711. } else {
  1712. return tsLink;
  1713. }
  1714. } else {
  1715. return tsLink;
  1716. }
  1717. }
  1718. );
  1719. }
  1720. ).join('\n'), logysf, logysi);
  1721. }
  1722. } catch (e) {}
  1723. }
  1724. } catch (e) {}
  1725. return endlist(allLines.map(item=>item.line).join('\n'));
  1726. }
  1727. }
  1728. }
  1729. }
  1730. }
  1731. }
  1732. } else {
  1733. return text;
  1734. }
  1735. } else {
  1736. return text;
  1737. }
  1738. } catch (e) {
  1739. return text;
  1740. }
  1741. }
  1742. ;
  1743. const prunerm3u8 = (text)=>{
  1744. try {
  1745. if (!shouldStopExecution) {
  1746. if (text) {
  1747. if (!itemm3u8.test(text)) {
  1748. return text;
  1749. } else {
  1750. if (ggljbmd.test(text)) {
  1751. shouldStopExecution = true;
  1752. return text;
  1753. } else {
  1754. if (!shouldStopExecution) {
  1755. const lines = text.split('\n');
  1756. const keyCount = lines.filter(line=>new RegExp(tyad1021,'i').test(line)).length;
  1757. if (keyCount >= 2) {
  1758. return text;
  1759. } else {
  1760. let discontinuityCount = 0;
  1761. const filteredLines = lines.filter(line=>{
  1762. if (new RegExp(tyad2,'i').test(line)) {
  1763. discontinuityCount++;
  1764. return false;
  1765. }
  1766. return true;
  1767. }
  1768. );
  1769. try {
  1770. if (!dypd.test(打印开关)) {
  1771. if (discontinuityCount > 1) {
  1772. console.log(logysa + logysj + "-已经发现] ✂" + '已删除《' + discontinuityCount + '》个' + tyad2 + logysj, logysf);
  1773. }
  1774. }
  1775. } catch (e) {}
  1776. return endlist(removeprunerm3u8a(filteredLines.join('\n')));
  1777. }
  1778. } else {
  1779. return text;
  1780. }
  1781. }
  1782. }
  1783. } else {
  1784. return text;
  1785. }
  1786. } else {
  1787. return text;
  1788. }
  1789. } catch (e) {
  1790. return text;
  1791. }
  1792. }
  1793. ;
  1794. const m3u8adgl = (textout)=>{
  1795. try {
  1796. try {
  1797. textout = proqcb(textout);
  1798. } catch (e) {}
  1799. try {
  1800. textout = proqcc(textout);
  1801. } catch (e) {}
  1802. try {
  1803. textout = prunerm3u8(textout);
  1804. } catch (e) {}
  1805. try {
  1806. textout = removeprunerm3u8e(textout);
  1807. } catch (e) {}
  1808. try {
  1809. textout = removeprunerm3u8b(textout);
  1810. } catch (e) {}
  1811. try {
  1812. textout = removeprunerm3u8c(textout);
  1813. } catch (e) {}
  1814. try {
  1815. textout = removeprunerm3u8d(textout);
  1816. } catch (e) {}
  1817. try {
  1818. textout = durationtaragt(textout);
  1819. } catch (e) {}
  1820. try {
  1821. textout = taragtduration(textout);
  1822. } catch (e) {}
  1823. try {
  1824. textout = endlist(textout);
  1825. } catch (e) {}
  1826. /*console.log("测试广告:\n"+textout);*/
  1827. return textout;
  1828. } catch (e) {
  1829. return textout;
  1830. }
  1831. }
  1832. ;
  1833. let realFetch = self.fetch;
  1834. self.fetch = new Proxy(self.fetch,{
  1835. apply: function(target, thisArg, args) {
  1836. try {
  1837. let url = urlFromArg(args[0]);
  1838. let item = matchM3u(url);
  1839. if (item) {
  1840. if (ggljbmd.test(url) || shouldStopExecution) {
  1841. shouldStopExecution = true;
  1842. return Reflect.apply(target, thisArg, args);
  1843. } else {
  1844. m3u8gglj = url;
  1845. try {
  1846. if (isValidM3U8Url(m3u8gglj)) {
  1847. m3u8bflj = m3u8gglj;
  1848. try {
  1849. console.clear();
  1850. } catch (e) {}
  1851. console.log("播放链接:" + m3u8bflj);
  1852. }
  1853. } catch (e) {}
  1854. if (!shouldStopExecution) {
  1855. return realFetch.apply(thisArg, args).then(realResponse=>{
  1856. try {
  1857. if (!realResponse || !realResponse.ok) {
  1858. return realResponse;
  1859. } else {
  1860. return realResponse.text().then(textin=>{
  1861. try {
  1862. if (M3umatch(textin)) {
  1863. return realResponse;
  1864. } else {
  1865. if (!new RegExp(tyad5,'i').test(textin)) {
  1866. return realResponse;
  1867. } else {
  1868. if (!tyad1051.test(textin)) {
  1869. return realResponse;
  1870. } else {
  1871. let textout = proqca(textin, item);
  1872. try {
  1873. textout = m3u8adgl(textout);
  1874. } catch (e) {}
  1875. try {
  1876. if (M3umatch(textout)) {
  1877. return realResponse;
  1878. }
  1879. } catch (e) {}
  1880. if (textout !== textin) {
  1881. return new Response(textout,{
  1882. status: realResponse.status,
  1883. statusText: realResponse.statusText,
  1884. headers: realResponse.headers
  1885. });
  1886. } else {
  1887. return realResponse;
  1888. }
  1889. }
  1890. }
  1891. }
  1892. } catch (e) {
  1893. return realResponse;
  1894. }
  1895. }
  1896. );
  1897. }
  1898. } catch (e) {
  1899. return realResponse;
  1900. }
  1901. }
  1902. );
  1903. } else {
  1904. return Reflect.apply(target, thisArg, args);
  1905. }
  1906. }
  1907. } else {
  1908. return Reflect.apply(target, thisArg, args);
  1909. }
  1910. } catch (e) {
  1911. return Reflect.apply(target, thisArg, args);
  1912. }
  1913. }
  1914. });
  1915. let originalOpen = self.XMLHttpRequest.prototype.open;
  1916. self.XMLHttpRequest.prototype.open = new Proxy(self.XMLHttpRequest.prototype.open,{
  1917. apply: async function(target, thisArg, args) {
  1918. try {
  1919. if (!shouldStopExecution) {
  1920. let url = urlFromArg(args[1]);
  1921. let item = matchM3u(url);
  1922. if (item) {
  1923. if (ggljbmd.test(url) || shouldStopExecution) {
  1924. shouldStopExecution = true;
  1925. return Reflect.apply(target, thisArg, args);
  1926. } else {
  1927. m3u8gglj = url;
  1928. try {
  1929. if (isValidM3U8Url(m3u8gglj)) {
  1930. m3u8bflj = m3u8gglj;
  1931. try {
  1932. console.clear();
  1933. } catch (e) {}
  1934. console.log("播放链接:" + m3u8bflj);
  1935. }
  1936. } catch (e) {}
  1937. try {
  1938. thisArg.addEventListener('readystatechange', async function() {
  1939. try {
  1940. if (thisArg.readyState !== 4) {
  1941. return;
  1942. } else {
  1943. const type = thisArg.responseType;
  1944. if (type !== '' && type !== 'text') {
  1945. return;
  1946. } else {
  1947. let textin = thisArg.responseText;
  1948. try {
  1949. if (M3umatch(textin)) {
  1950. return;
  1951. }
  1952. } catch (e) {}
  1953. if (!new RegExp(tyad5,'i').test(textin)) {
  1954. return;
  1955. } else {
  1956. if (!tyad1051.test(textin)) {
  1957. return;
  1958. } else {
  1959. let textout = proqca(textin, item);
  1960. try {
  1961. textout = m3u8adgl(textout);
  1962. } catch (e) {}
  1963. try {
  1964. if (M3umatch(textout)) {
  1965. return;
  1966. }
  1967. } catch (e) {}
  1968. if (textout !== textin) {
  1969. Reflect.defineProperty(thisArg, 'response', {
  1970. value: textout
  1971. });
  1972. Reflect.defineProperty(thisArg, 'responseText', {
  1973. value: textout
  1974. });
  1975. } else {
  1976. return;
  1977. }
  1978. }
  1979. }
  1980. }
  1981. }
  1982. } catch (e) {
  1983. return;
  1984. }
  1985. });
  1986. } catch (e) {}
  1987. return Reflect.apply(target, thisArg, args);
  1988. }
  1989. } else {
  1990. return Reflect.apply(target, thisArg, args);
  1991. }
  1992. } else {
  1993. return Reflect.apply(target, thisArg, args);
  1994. }
  1995. } catch (e) {
  1996. return Reflect.apply(target, thisArg, args);
  1997. }
  1998. }
  1999. });
  2000. }
  2001. } catch (e) {}
  2002. } else {
  2003. alert("当前浏览器不支持 Proxy,无法执行相关功能。");
  2004. }
  2005. } catch (e) {}
  2006. }
  2007. } catch (e) {}
  2008. }
  2009. )();