From 4697776b5ddf6a28a2e9bef4e907e569d9ddc478 Mon Sep 17 00:00:00 2001 From: "Y.D.X" <73375426+YDX-2147483647@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:55:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BC=96=E8=BE=91=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=20(#12)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: CJJ-amateur-programmer <161215070+CJJ-amateur-programmer@users.noreply.github.com> --- ...46\240\217\350\257\276\347\250\213-GUI.md" | 4 ++- ...0\217\350\257\276\347\250\213-GUI.user.js" | 29 ++++++++++++++++--- ...71\346\240\217\350\257\276\347\250\213.md" | 2 +- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git "a/TamperMonkey/BIT-\344\271\220\345\255\246-\344\277\256\346\224\271\344\276\247\350\276\271\346\240\217\350\257\276\347\250\213-GUI.md" "b/TamperMonkey/BIT-\344\271\220\345\255\246-\344\277\256\346\224\271\344\276\247\350\276\271\346\240\217\350\257\276\347\250\213-GUI.md" index a6ddc1b..30d5b08 100644 --- "a/TamperMonkey/BIT-\344\271\220\345\255\246-\344\277\256\346\224\271\344\276\247\350\276\271\346\240\217\350\257\276\347\250\213-GUI.md" +++ "b/TamperMonkey/BIT-\344\271\220\345\255\246-\344\277\256\346\224\271\344\276\247\350\276\271\346\240\217\350\257\276\347\250\213-GUI.md" @@ -15,11 +15,13 @@ - “**更新课程并修改侧边栏**”将发送网络请求并获取最新的课程情况,列在“显示的课程”一栏; - “**仅修改侧边栏**”则从本地篡改猴储存中获取课程情况。 +此外在弹窗中双击格子,还可**编辑课程名称**(粘贴文本时会自动去除换行和格式)。完成后请按Enter或者单击旁边空白处来退出编辑模式。 + ## 兼容性 这段脚本与“[BIT-乐学-修改侧边栏课程](https://greasyfork.org/scripts/470832)”矛盾,同时启用时效果不确定。 - 此脚本的操作方式远比无GUI版直观,直接拖动即可; -- 无GUI版能修改名称、图标,此脚本目前还不能。 +- 无GUI版能修改图标,此脚本目前还不能。 欢迎有志之士前往 [YDX-2147483647/BIT-enhanced](https://github.com/YDX-2147483647/BIT-enhanced) 帮忙合并两段脚本。 diff --git "a/TamperMonkey/BIT-\344\271\220\345\255\246-\344\277\256\346\224\271\344\276\247\350\276\271\346\240\217\350\257\276\347\250\213-GUI.user.js" "b/TamperMonkey/BIT-\344\271\220\345\255\246-\344\277\256\346\224\271\344\276\247\350\276\271\346\240\217\350\257\276\347\250\213-GUI.user.js" index 4e950a3..777a16d 100644 --- "a/TamperMonkey/BIT-\344\271\220\345\255\246-\344\277\256\346\224\271\344\276\247\350\276\271\346\240\217\350\257\276\347\250\213-GUI.user.js" +++ "b/TamperMonkey/BIT-\344\271\220\345\255\246-\344\277\256\346\224\271\344\276\247\350\276\271\346\240\217\350\257\276\347\250\213-GUI.user.js" @@ -1,7 +1,7 @@ // ==UserScript== // @name BIT-乐学-修改侧边栏课程-GUI // @namespace http://tampermonkey.net/ -// @version 0.1.1 +// @version 0.1.2 // @description 修改侧边栏显示的课程 // @license GPL-3.0-or-later // @supportURL https://github.com/YDX-2147483647/BIT-enhanced/issues @@ -26,7 +26,7 @@ popup_cover.style = 'width:100%;height:100%;background-color:rgba(0,0,0,0.6);position:fixed;inset:0px;z-index:2000' function rewrite_sidebar (shown_courses) { - const current_id = (location.href.match(/(?<=id=)\w+/) || [])[0] + const current_id = (document.querySelector('[data-key="coursehome"].active_tree_node')?.href?.match(/(?<=id=)\w+/) || [])[0] const mycourses = document.querySelector('li:has([data-key="mycourses"])') const sidebar_course_list = mycourses.parentNode @@ -116,6 +116,9 @@ ul#shown_courses>li,ul#hidden_courses>li,div.table-title{ width: 100%; text-align: center; } +span[contenteditable='true']{ + border:thin solid #C0C0C0; +} @@ -180,7 +183,16 @@ ul#shown_courses>li,ul#hidden_courses>li,div.table-title{ } } }) - shown_li.innerHTML = `
${shown_courses[i][1]}
` + shown_li.innerHTML = + ` +
+
+ + ${shown_courses[i][1]} + +
+
+
` popup.querySelector('#shown_courses').append(shown_li) } for (let j = 0; j < hidden_courses.length; j++) { @@ -203,7 +215,16 @@ ul#shown_courses>li,ul#hidden_courses>li,div.table-title{ } } }) - hidden_li.innerHTML = `
${hidden_courses[j][1]}
` + hidden_li.innerHTML = + ` +
+
+ + ${hidden_courses[j][1]} + +
+
+
` popup.querySelector('#hidden_courses').append(hidden_li) } document.body.append(popup_cover) diff --git "a/TamperMonkey/BIT-\344\271\220\345\255\246-\344\277\256\346\224\271\344\276\247\350\276\271\346\240\217\350\257\276\347\250\213.md" "b/TamperMonkey/BIT-\344\271\220\345\255\246-\344\277\256\346\224\271\344\276\247\350\276\271\346\240\217\350\257\276\347\250\213.md" index 3d97e57..578c208 100644 --- "a/TamperMonkey/BIT-\344\271\220\345\255\246-\344\277\256\346\224\271\344\276\247\350\276\271\346\240\217\350\257\276\347\250\213.md" +++ "b/TamperMonkey/BIT-\344\271\220\345\255\246-\344\277\256\346\224\271\344\276\247\350\276\271\346\240\217\350\257\276\347\250\213.md" @@ -44,7 +44,7 @@ 这段脚本与“[BIT-乐学-修改侧边栏课程-GUI](https://greasyfork.org/zh-CN/scripts/488788)”矛盾,同时启用时效果不确定。 -- 此脚本能修改名称、图标,GUI版目前还不能; +- 此脚本能修改图标,GUI版目前还不能; - GUI版的操作方式远比此脚本直观,直接拖动即可; 欢迎有志之士前往 [YDX-2147483647/BIT-enhanced](https://github.com/YDX-2147483647/BIT-enhanced) 帮忙合并两段脚本。