// ==UserScript== // @name 取得動畫瘋 m3u8 網址 // @namespace https://blog.maple3142.net/ // @version 0.2 // @description RT // @author maple3142 // @match https://ani.gamer.com.tw/animeVideo.php?sn=* // @require https://cdn.jsdelivr.net/npm/m3u8-parser@4.2.0/dist/m3u8-parser.min.js // @grant none // @downloadURL none // ==/UserScript== ;(function($) { 'use strict' //in order to get videojs instance requirejs.config({ baseUrl: '//i2.bahamut.com.tw', waitSeconds: 0, paths: { order: 'js/order' }, shim: { viblast: {}, vastvpaid: { deps: ['videojs'] } } }) requirejs(['order!videojs'], videojs => { videojs.players = new Proxy(videojs.players, { deleteProperty(t, k, r) { //keep videojs.players.ani_video from being deleted } }) }) function render(pls) { const html = pls .map( pl => `
` ) .join('') $('.anime_name').append(`
${html}
`) } const it = setInterval(function() { if (!videojs.players.ani_video.K.src) return clearInterval(it) const playlisturl = videojs.players.ani_video.K.src const baseurl = playlisturl.replace(/index\.m3u8.*/, '') fetch(playlisturl) .then(r => r.text()) .then(m3u8 => { const parser = new m3u8Parser.Parser() parser.push(m3u8) parser.end() const pls = parser.manifest.playlists.map(pl => ({ url: 'https:' + baseurl + pl.uri, res: pl.attributes.RESOLUTION })) window.M3U8_PLAYLIST = pls //EXPOSE return pls }) .then(render) }, 500) //extra: block anti adblock alert const orig_alert = alert alert = function(t) { if (t.includes('由於擋廣告插件會影響播放器運作')) return orig_alert(t) } })(jQuery)