xmoj-script 2.2.2 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Update.json CHANGED
@@ -3043,6 +3043,32 @@
3043
3043
  }
3044
3044
  ],
3045
3045
  "Notes": "No release notes were provided for this release."
3046
+ },
3047
+ "2.3.0": {
3048
+ "UpdateDate": 1757851277491,
3049
+ "Prerelease": false,
3050
+ "UpdateContents": [
3051
+ {
3052
+ "PR": 839,
3053
+ "Description": "Fix formatting in feedback card text"
3054
+ },
3055
+ {
3056
+ "PR": 852,
3057
+ "Description": "Fix the submit button on some pages"
3058
+ }
3059
+ ],
3060
+ "Notes": "随着 CI 更新, 相信以后的 release 都会有 release notes("
3061
+ },
3062
+ "2.3.1": {
3063
+ "UpdateDate": 1758944205783,
3064
+ "Prerelease": true,
3065
+ "UpdateContents": [
3066
+ {
3067
+ "PR": 856,
3068
+ "Description": "修复由于 PHPSESSID 启用了 httpOnly 导致的后台不可用"
3069
+ }
3070
+ ],
3071
+ "Notes": "本版本修复了由于 PHPSESSID 启用了 httpOnly 导致的后台不可用"
3046
3072
  }
3047
3073
  }
3048
3074
  }
package/XMOJ.user.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // ==UserScript==
2
2
  // @name XMOJ
3
- // @version 2.2.2
3
+ // @version 2.3.1
4
4
  // @description XMOJ增强脚本
5
5
  // @author @XMOJ-Script-dev, @langningchen and the community
6
6
  // @namespace https://github/langningchen
@@ -20,6 +20,7 @@
20
20
  // @grant unsafeWindow
21
21
  // @grant GM_setValue
22
22
  // @grant GM_getValue
23
+ // @grant GM_cookie
23
24
  // @homepage https://www.xmoj-bbs.me/
24
25
  // @supportURL https://support.xmoj-bbs.me/form/8050213e-c806-4680-b414-0d1c48263677
25
26
  // @connect api.xmoj-bbs.tech
@@ -479,6 +480,20 @@ let RequestAPI = (Action, Data, CallBack) => {
479
480
  Session = Temp[i].split("=")[1];
480
481
  }
481
482
  }
483
+ if (Session === "") { //The cookie is httpOnly
484
+ GM.cookie.set({
485
+ name: 'PHPSESSID',
486
+ value: (Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2)).substring(0, 28),
487
+ path: "/"
488
+ })
489
+ .then(() => {
490
+ console.log('Reset PHPSESSID successfully.');
491
+ location.reload(); //Refresh the page to auth with the new PHPSESSID
492
+ })
493
+ .catch((error) => {
494
+ console.error(error);
495
+ });
496
+ }
482
497
  let PostData = {
483
498
  "Authentication": {
484
499
  "SessionID": Session, "Username": CurrentUsername,
@@ -1010,7 +1025,17 @@ async function main() {
1010
1025
  });
1011
1026
  PopupUL.children[5].addEventListener("click", () => {
1012
1027
  clearCredential();
1013
- document.cookie = "PHPSESSID=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/"; //This is how you remove a cookie?
1028
+ GM.cookie.set({
1029
+ name: 'PHPSESSID',
1030
+ value: (Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2)).substring(0, 28),
1031
+ path: "/"
1032
+ })
1033
+ .then(() => {
1034
+ console.log('Reset PHPSESSID successfully.');
1035
+ })
1036
+ .catch((error) => {
1037
+ console.error(error);
1038
+ }); //We can no longer rely of the server to set the cookie for us
1014
1039
  location.href = "https://www.xmoj.tech/logout.php";
1015
1040
  });
1016
1041
  Array.from(PopupUL.children).forEach(item => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmoj-script",
3
- "version": "2.2.2",
3
+ "version": "2.3.1",
4
4
  "description": "an improvement script for xmoj.tech",
5
5
  "main": "AddonScript.js",
6
6
  "scripts": {