Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
qianjiachun committed Feb 12, 2022
1 parent b46d8bd commit a1c7bf4
Showing 1 changed file with 24 additions and 31 deletions.
55 changes: 24 additions & 31 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
// @author qianjiachun
// @icon data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMjJweCIgaGVpZ2h0PSIyMHB4IiB2aWV3Qm94PSIwIDAgMjIgMjAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8dGl0bGU+am95c291bmQvc2VsZWN0ZWQ8L3RpdGxlPgogICAgPGRlZnM+CiAgICAgICAgPGxpbmVhckdyYWRpZW50IHgxPSI1MCUiIHkxPSIwJSIgeDI9IjUwJSIgeTI9IjEwMCUiIGlkPSJsaW5lYXJHcmFkaWVudC0xIj4KICAgICAgICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iI0YwQ0I5NSIgb2Zmc2V0PSIwJSI+PC9zdG9wPgogICAgICAgICAgICA8c3RvcCBzdG9wLWNvbG9yPSIjRTlCRTgwIiBvZmZzZXQ9IjEwMCUiPjwvc3RvcD4KICAgICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPGcgaWQ9ImpveXNvdW5kL3NlbGVjdGVkIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgICAgICA8ZyBpZD0i57yW57uEIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgyLjc4NTc1MCwgMC43MTQyMjUpIiBmaWxsPSJ1cmwoI2xpbmVhckdyYWRpZW50LTE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MDEzMDk2MjcgNy4wNzE1LDkuNjQzMDI1IEM3LjA3MTUsMTAuMjcyNzMwNyA3LjU4NDQ5MDQyLDEwLjc4NTc3NSA4LjIxNDI1LDEwLjc4NTc3NSBDOC44NDM4NTc2MywxMC43ODU3NzUgOS4zNTcsMTAuMjcyNjMyNiA5LjM1Nyw5LjY0MzAyNSBDOS4zNTcsOS4wMTMxOTQzMyA4Ljg0Mzg4NDU3LDguNTAwMDI1IDguMjE0MjUsOC41MDAwMjUgWiIgaWQ9IuW9oueKtiI+PC9wYXRoPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+
// @namespace https://github.com/qianjiachun/joysound-tampermonkey
// @version 2022.02.12.01
// @version 2022.02.12.02
// @description 🎵✨通用网页视频音效增强/优化。Enhance/Optimize video sound in web.
// @match *://*/*
// @include *://*/*
// @connect yximgs.com
// @resource asyncPlayerPlugins https://static.yximgs.com/udata/pkg/acfun-player/asyncPlayerPlugins.083319.js
// @grant unsafeWindow
// @grant GM_registerMenuCommand
// @grant GM_xmlhttpRequest
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_getResourceText
// @license MIT
// ==/UserScript==

Expand Down Expand Up @@ -42,23 +43,9 @@ class CustomJoysound {

async function enableJoysound() {
// 开启joysound
// 判断有没有加载过js
if (!hasLoadedJs) {
// 先判断本地有没有js缓存,没有就下载,然后加载
let js = GM_getValue(LOCAL_JS);
let jsVersion = GM_getValue(LOCAL_JS_VERSION);
if (js && jsVersion == JS_VERSION) {
eval(js);
} else {
let js = await getJs();
GM_setValue(LOCAL_JS, js);
GM_setValue(LOCAL_JS_VERSION, JS_VERSION);
eval(js);
}
hasLoadedJs = true;
loadJs();
}

// js确保已经加载
if (joysoundList.length > 0) {
for (let i = 0; i < joysoundList.length; i++) {
joysoundList[i].setEnabled(1);
Expand Down Expand Up @@ -113,20 +100,26 @@ function init() {
}

function getJs() {
return new Promise(resolve => {
GM_xmlhttpRequest({
method: "GET",
url: "https://static.yximgs.com/udata/pkg/acfun-player/asyncPlayerPlugins.083319.js",
responseType: "text",
onload: function(response) {
let ret = response.response;
const STR = "b.safari";
let index = ret.indexOf(STR) + STR.length + 3;
let js = ret.slice(0, index) + "Joysound=e;" + ret.slice(index);
resolve(js);
}
});
})
const STR = "b.safari";
let ret = GM_getResourceText("asyncPlayerPlugins");
let index = ret.indexOf(STR) + STR.length + 3;
let js = ret.slice(0, index) + "Joysound=e;" + ret.slice(index);
return js;
}

function loadJs() {
// 判断有没有加载过js
let js = GM_getValue(LOCAL_JS);
let jsVersion = GM_getValue(LOCAL_JS_VERSION);
if (js && jsVersion == JS_VERSION) {
eval(js);
} else {
let js = getJs();
GM_setValue(LOCAL_JS, js);
GM_setValue(LOCAL_JS_VERSION, JS_VERSION);
eval(js);
}
hasLoadedJs = true;
}

function hasVideoNode() {
Expand Down

0 comments on commit a1c7bf4

Please sign in to comment.