// ==UserScript== // @name Anime News Network HTML5 Video // @namespace DoomTay // @description Replaces built-in Flash player with HTML5 // @include https://www.animenewsnetwork.com/video/* // @version 0.5.0 // @grant none // @run-at document-start // @downloadURL none // ==/UserScript== var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { mutation.addedNodes.forEach(findSWFScript); }); }); var config = { childList: true, subtree: true }; observer.observe(document, config); for(var i = 0; i < document.scripts.length; i++) { findSWFScript(document.scripts[i]); } function findSWFScript(start) { if(start.nodeName == "SCRIPT" && start.src.includes("assets/bd277df0dd3412fa7734d08320ecbe1cd9089168.js")) { observer.disconnect(); start.on("load",function() { var oldInit = window.Video.init_player; window.Video.init_player = function(vid) { if(vid.flashvars["GetVideo"]) { this.init_player = null; this.initialized = true; $("flash-required-message").hide(); jQuery.get(vid.flashvars["GetVideo"],function(data) { var newVideo = document.createElement("video"); newVideo.width = 480; newVideo.height = 360; newVideo.controls = true; newVideo.src = data.querySelector("flv bitrate").textContent; newVideo.autoplay = document.location.hash == "#play-1"; newVideo.poster = data.querySelector("Still").textContent; $("video-player-area").append(newVideo); }) } else if(vid.flash.movie && (vid.flash.movie.includes("youtube") || vid.flash.movie.includes("hulu"))) { vid.flash.movie = vid.flash.movie.replace("http:","https:"); window.UFO.pluginType = "npapi"; window.UFO.hasFlashVersion = function(major, release) { if(major == 9 && release == 115) return true; else return (UFO.fv[0] > major || (UFO.fv[0] == major && UFO.fv[1] >= release)) ? true : false; } oldInit.apply(this, arguments); } else oldInit.apply(this, arguments); } }); } }