diff --git a/AddonScript.js b/AddonScript.js index 28722a63..66dff33f 100644 --- a/AddonScript.js +++ b/AddonScript.js @@ -1 +1,6 @@ -console.log("AddonScript.js has loaded."); +/* +DO NOT MODIFY THIS FILE, +IT IS KEPT HERE FOR BACKWARD COMPATIBILITY ONLY + */ + +console.warn("Please update XMOJ-Script!"); \ No newline at end of file diff --git a/Update.json b/Update.json index f0d3fa62..45b5cb96 100644 --- a/Update.json +++ b/Update.json @@ -2729,6 +2729,17 @@ } ], "Notes": "No release notes were provided for this release." + }, + "1.3.2": { + "UpdateDate": 1739187728351, + "Prerelease": true, + "UpdateContents": [ + { + "PR": 778, + "Description": "Change how we load addonscript (transition from GitHub pages to Cloudflare KV) + Fix *that* console error" + } + ], + "Notes": "No release notes were provided for this release." } } } \ No newline at end of file diff --git a/XMOJ.user.js b/XMOJ.user.js index 3821580f..5c7f43e9 100644 --- a/XMOJ.user.js +++ b/XMOJ.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name XMOJ -// @version 1.3.1 +// @version 1.3.2 // @description XMOJ增强脚本 // @author @XMOJ-Script-dev, @langningchen and the community // @namespace https://github/langningchen @@ -465,10 +465,7 @@ let RequestAPI = (Action, Data, CallBack) => { try { CallBack(JSON.parse(Response.responseText)); } catch (Error) { - console.log(Response.responseText); - CallBack({ - "Success": false, "Message": "JSON解析错误:" + Error, "Data": null - }); + console.error(Response.responseText); } } }); @@ -1153,14 +1150,13 @@ async function main() { new bootstrap.Modal(document.getElementById("UpdateModal")).show(); } }); - fetch(ServerURL + "/AddonScript.js", {cache: "no-cache"}) - .then((Response) => { - return Response.text(); - }) - .then((Response) => { - eval(Response); - }); - + RequestAPI("GetAddOnScript", {}, (Response) => { + if (Response.Success) { + eval(Response.Data["Script"]); + } else { + console.warn("Fetch AddOnScript failed: " + Response.Message); + } + }); let ToastContainer = document.createElement("div"); ToastContainer.classList.add("toast-container", "position-fixed", "bottom-0", "end-0", "p-3"); document.body.appendChild(ToastContainer); diff --git a/package.json b/package.json index cf0cc01d..36ad9922 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xmoj-script", - "version": "1.3.1", + "version": "1.3.2", "description": "an improvement script for xmoj.tech", "main": "AddonScript.js", "scripts": {