Skip to content

Commit 12a2f91

Browse files
committed
update
1 parent 977e9b7 commit 12a2f91

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

leetcode-discuss-docs/index.js

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
// ==UserScript==
22
// @name leetcode-discuss-docs
33
// @namespace leetcode-discuss-docs
4-
// @version 0.0.1
4+
// @version 0.0.1-test6
55
// @author wuxin0011
66
// @description 讨论区添加目录导航
77
// @license MIT
8-
// @supportURL https://github.com/wuxin0011/tampermonkey-script/
9-
// @downloadURL https://scriptcat.org/zh-CN/script-show-page/4374
8+
// @supportURL https://scriptcat.org/zh-CN/script-show-page/4374
109
// @icon https://pic.leetcode.cn/1760157013-KiWvys-book-bookmark-icon_34486.png
1110
// @match https://leetcode.cn/circle/discuss/*
1211
// @match https://leetcode.cn/discuss/*
13-
// @match https://leetcode.cn/
14-
// @match https://leetcode.cn/problems/*
1512
// @match https://leetcode.com/circle/discuss/*
1613
// @match https://leetcode.com/discuss/*
17-
// @match https://leetcode.com/problems/*
18-
// @match https://leetcode.com
1914
// @resource tobotcss https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.32.2/tocbot.css
2015
// @require https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.32.2/tocbot.min.js
2116
// @grant GM_addStyle
@@ -28,6 +23,9 @@
2823

2924
(function() {
3025
'use strict';
26+
if(window.location.href == 'https://leetcode.cn/discuss/' || window.location.href == 'https://leetcode.com/discuss/') {
27+
return
28+
}
3129

3230
// 添加 Tocbot CSS
3331
GM_addStyle(GM_getResourceText('tobotcss'));
@@ -37,23 +35,37 @@
3735

3836
install_left = install_left == undefined ||install_left == 'undefined' || install_left == 'null' || install_left == false ? false : true
3937

40-
GM_registerMenuCommand('切换目录安装位置',()=>{
38+
GM_registerMenuCommand(`目录安装到${install_left ? '右侧':'左侧'}`,()=>{
4139
GM_setValue(key,!install_left)
4240
window.location.reload()
4341
})
4442

43+
44+
GM_registerMenuCommand('更新',()=>{
45+
window.open('https://scriptcat.org/zh-CN/script-show-page/4374','_blank')
46+
})
47+
4548
// 自定义样式 - 修复空白、固定位置和暗色模式
4649
GM_addStyle(`
4750
/* 屏蔽讨论区目录 */
48-
.t6Fde{ display:none !important;}
51+
/* .t6Fde{ display:none !important;}*/
52+
/* 屏蔽讨论区目录 */
53+
${install_left ?
54+
` .t6Fde{
55+
display:none !important;
56+
}`:
57+
` .t6Fde{
58+
visibility: hidden !important;
59+
display:inline-block !important;
60+
}`}
4961
.tocbot-sidebar {
5062
position: fixed;
51-
top: 60px;
63+
top: 0;
5264
${install_left ? "left : 0px;": "right: 0px;"}
5365
width:auto;
54-
max-width:280px;
55-
min-width:200px;
56-
max-height: calc(100vh - 120px);
66+
max-width:300px;
67+
min-width:230px;
68+
max-height: calc(100vh - 20px);
5769
background: white;
5870
border-radius: 8px;
5971
padding: 16px;
@@ -392,6 +404,15 @@
392404
}
393405
`);
394406

407+
function f0() {
408+
if(!install_left) return;
409+
let dom = document.querySelector('.t6Fde').previousElementSibling
410+
dom.className = "relative flex flex-1 justify-end mr-10"
411+
}
412+
setTimeout(() => {
413+
f0()
414+
}, 1000);
415+
395416
function initTocbot() {
396417
// 移除已存在的目录
397418
const existingToc = document.querySelector('.tocbot-sidebar');

0 commit comments

Comments
 (0)