Greasy Fork

Greasy Fork is available in English.

取得動畫瘋 m3u8 網址

RT

当前为 2018-03-04 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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/[email protected]/dist/m3u8-parser.min.js
// @grant        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 =>
					`<div><label for="${pl.res.height}p">${pl.res.height}P: </label><input id="${
						pl.res.height
					}p" value="${pl.url}" style="width: 500px;"></div>`
			)
			.join('')
		$('.anime_name').append(`<div id="anigamer_m3u8_warpper">${html}</div>`)
	}
	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)