您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Replace Flash Player with HTML5 Player on tingshen.court.gov.cn
当前为
- // ==UserScript==
- // @name HTML5 on TINGSHEN
- // @namespace https://coding.net/u/sffxzzp
- // @version 0.3
- // @description Replace Flash Player with HTML5 Player on tingshen.court.gov.cn
- // @author sffxzzp
- // @match *://tingshen.court.gov.cn/live*
- // @match *://tingshen.court.gov.cn/court*
- // @require https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.js
- // @require https://cdn.jsdelivr.net/npm/hls.js/dist/hls.min.js
- // @icon http://tingshen.court.gov.cn/static/img/favorite.ico
- // @connect player.videoincloud.com
- // @grant GM_xmlhttpRequest
- // ==/UserScript==
- (function() {
- var util = (function () {
- function util() {}
- util.xhr = function (xhrData) {
- return new Promise(function(resolve, reject) {
- if (!xhrData.xhr) {
- GM_xmlhttpRequest({
- method: xhrData.method || "get",
- url: xhrData.url,
- responseType: xhrData.type || "",
- timeout: 3e4,
- onload: function onload(res) {
- return resolve({ response: res, body: res.response });
- },
- onerror: reject,
- ontimeout: reject
- });
- } else {
- var xhr = new XMLHttpRequest();
- xhr.open(
- xhrData.method || "get",
- xhrData.url,
- true
- );
- if (xhrData.method === "POST") {
- xhr.setRequestHeader(
- "content-type",
- "application/x-www-form-urlencoded; charset=utf-8"
- );
- }
- if (xhrData.cookie) xhr.withCredentials = true;
- xhr.responseType = xhrData.responseType || "";
- xhr.timeout = 3e4;
- xhr.onload = function(ev) {
- var evt = ev.target;
- resolve({ response: evt, body: evt.response });
- };
- xhr.onerror = reject;
- xhr.ontimeout = reject;
- xhr.send(xhrData.data);
- }
- });
- };
- return util;
- })();
- var h5onCourt = (function () {
- function h5onCourt() {};
- h5onCourt.prototype.parseDOM = function (string) {
- var div = document.createElement('div');
- div.innerHTML = string;
- return div;
- }
- h5onCourt.prototype.addPlayer = function (url) {
- var h5css = document.createElement('link');
- h5css.rel = 'stylesheet';
- h5css.href = 'https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.css';
- document.head.appendChild(h5css);
- var iframes = document.getElementsByTagName('iframe');
- var container = iframes[iframes.length-1].parentNode;
- container.innerHTML = '<div id="dplayer" style="width: 100%; height: 100%;"></div>';
- var dp = new DPlayer({
- container: container.children[0],
- video: {
- url: url,
- type: 'hls'
- }
- });
- }
- h5onCourt.prototype.run = function () {
- var _this = this;
- var iframes = document.getElementsByTagName('iframe');
- var extLink = iframes[iframes.length-1].getAttribute('src');
- util.xhr({
- url: extLink
- }).then(function (res) {
- var node = _this.parseDOM(res.body);
- var tIndex = 0;
- for (tIndex=0;tIndex<node.children.length;tIndex++) {
- if (node.children[tIndex].innerHTML.indexOf('flashvars')>-1) {
- break;
- }
- }
- var flashvars = node.children[tIndex].innerHTML;
- flashvars = /flashvars.file.*?=.*?encodeURIComponent\(\"(.+?)\"\)/.exec(flashvars)[1];
- if (flashvars.length>0) {
- _this.addPlayer(flashvars);
- }
- });
- };
- return h5onCourt;
- })();
- var program = new h5onCourt();
- program.run();
- })();