|
1 | 1 | // ==UserScript== |
2 | 2 | // @name leetcode-discuss-docs |
3 | 3 | // @namespace leetcode-discuss-docs |
4 | | -// @version 0.0.1 |
| 4 | +// @version 0.0.1-test6 |
5 | 5 | // @author wuxin0011 |
6 | 6 | // @description 讨论区添加目录导航 |
7 | 7 | // @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 |
10 | 9 | // @icon https://pic.leetcode.cn/1760157013-KiWvys-book-bookmark-icon_34486.png |
11 | 10 | // @match https://leetcode.cn/circle/discuss/* |
12 | 11 | // @match https://leetcode.cn/discuss/* |
13 | | -// @match https://leetcode.cn/ |
14 | | -// @match https://leetcode.cn/problems/* |
15 | 12 | // @match https://leetcode.com/circle/discuss/* |
16 | 13 | // @match https://leetcode.com/discuss/* |
17 | | -// @match https://leetcode.com/problems/* |
18 | | -// @match https://leetcode.com |
19 | 14 | // @resource tobotcss https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.32.2/tocbot.css |
20 | 15 | // @require https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.32.2/tocbot.min.js |
21 | 16 | // @grant GM_addStyle |
|
28 | 23 |
|
29 | 24 | (function() { |
30 | 25 | 'use strict'; |
| 26 | + if(window.location.href == 'https://leetcode.cn/discuss/' || window.location.href == 'https://leetcode.com/discuss/') { |
| 27 | + return |
| 28 | + } |
31 | 29 |
|
32 | 30 | // 添加 Tocbot CSS |
33 | 31 | GM_addStyle(GM_getResourceText('tobotcss')); |
|
37 | 35 |
|
38 | 36 | install_left = install_left == undefined ||install_left == 'undefined' || install_left == 'null' || install_left == false ? false : true |
39 | 37 |
|
40 | | - GM_registerMenuCommand('切换目录安装位置',()=>{ |
| 38 | + GM_registerMenuCommand(`目录安装到${install_left ? '右侧':'左侧'}`,()=>{ |
41 | 39 | GM_setValue(key,!install_left) |
42 | 40 | window.location.reload() |
43 | 41 | }) |
44 | 42 |
|
| 43 | + |
| 44 | + GM_registerMenuCommand('更新',()=>{ |
| 45 | + window.open('https://scriptcat.org/zh-CN/script-show-page/4374','_blank') |
| 46 | + }) |
| 47 | + |
45 | 48 | // 自定义样式 - 修复空白、固定位置和暗色模式 |
46 | 49 | GM_addStyle(` |
47 | 50 | /* 屏蔽讨论区目录 */ |
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 | + }`} |
49 | 61 | .tocbot-sidebar { |
50 | 62 | position: fixed; |
51 | | - top: 60px; |
| 63 | + top: 0; |
52 | 64 | ${install_left ? "left : 0px;": "right: 0px;"} |
53 | 65 | 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); |
57 | 69 | background: white; |
58 | 70 | border-radius: 8px; |
59 | 71 | padding: 16px; |
|
392 | 404 | } |
393 | 405 | `); |
394 | 406 |
|
| 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 | + |
395 | 416 | function initTocbot() { |
396 | 417 | // 移除已存在的目录 |
397 | 418 | const existingToc = document.querySelector('.tocbot-sidebar'); |
|
0 commit comments