Greasy Fork is available in English.

取得動畫瘋 m3u8 網址

RT

Pada tanggal 04 Maret 2018. Lihat %(latest_version_link).

// ==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
// ==/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)