|
5 | 5 | // @namespace https://github.com/v2hot/v2ex.min |
6 | 6 | // @homepageURL https://github.com/v2hot/v2ex.min#readme |
7 | 7 | // @supportURL https://github.com/v2hot/v2ex.min/issues |
8 | | -// @version 0.1.3 |
9 | | -// @description V2EX 极简风格,扁平化 UI,导航栏顶部固定,去除背景图片,支持黑暗模式,去除广告,去除不必要元素,支持隐藏头像,支持自定义样式。 |
10 | | -// @description:en V2EX minimalist style,扁平化 UI,导航栏顶部固定,去除背景图片,支持黑暗模式,去除广告,去除不必要元素,支持隐藏头像,支持自定义样式。 |
11 | | -// @description:zh-CN V2EX 极简风格,扁平化 UI,导航栏顶部固定,去除背景图片,支持黑暗模式,去除广告,去除不必要元素,支持隐藏头像,支持自定义样式。 |
| 8 | +// @version 0.1.4 |
| 9 | +// @description V2EX 极简风格,扁平化 UI,导航栏顶部固定,快捷按钮,去除背景图片,支持黑暗模式,去除广告,去除不必要元素,支持隐藏头像,支持自定义样式。 |
| 10 | +// @description:en V2EX minimalist style,扁平化 UI,导航栏顶部固定,快捷按钮,去除背景图片,支持黑暗模式,去除广告,去除不必要元素,支持隐藏头像,支持自定义样式。 |
| 11 | +// @description:zh-CN V2EX 极简风格,扁平化 UI,导航栏顶部固定,快捷按钮,去除背景图片,支持黑暗模式,去除广告,去除不必要元素,支持隐藏头像,支持自定义样式。 |
12 | 12 | // @icon https://www.v2ex.com/favicon.ico |
13 | 13 | // @author Pipecraft |
14 | 14 | // @license MIT |
|
25 | 25 | // ==/UserScript== |
26 | 26 | // |
27 | 27 | //// Recent Updates |
| 28 | +//// - 0.1.4 2023.04.18 |
| 29 | +//// - 显示快捷按钮 |
28 | 30 | //// - 0.1.3 2023.04.12 |
29 | 31 | //// - 隐藏最后回复者 |
30 | 32 | //// - 0.1.1 2023.04.12 |
|
229 | 231 | '*{box-shadow:unset !important;text-shadow:unset !important}.box,#Main .box,#Top,#Tabs,#Wrapper,#Bottom{background-image:unset !important;border:none !important}.cell,.box,.super.button,.topic_buttons,div[style*=border]{border:unset !important;background-image:unset !important}.count_livid{padding:0 !important;margin-right:0 !important;color:#999 !important;font-family:"Bender" !important;background-color:unset !important}body #Wrapper{background-color:#fff;--topic-link-color: #444444;--topic-link-hover-color: #217dfc;--primary-button-fill-color: #217dfc;--primary-button-text-color: #fff}body #Wrapper.Night{background-color:var(--box-background-color);--topic-link-color: #9caec7;--topic-link-hover-color: #a9bcd6;--primary-button-fill-color: #217dfc;--primary-button-text-color: #fff}a.topic-link:active,a.topic-link:link{color:var(--topic-link-color)}a.topic-link:hover{color:var(--topic-link-hover-color)}img{max-width:100%}body .super.button{background-color:var(--primary-button-fill-color);color:var(--primary-button-text-color);font-weight:400;border:transparent;border-radius:4px}body .super.button+.super.button{border-left:1px solid rgba(255,255,255,.2509803922) !important}body .super.button:not(.disable_now):hover,body .super.button:hover:enabled{background-color:var(--primary-button-fill-color) !important;opacity:85%;color:var(--primary-button-text-color) !important;font-weight:400;text-shadow:unset !important}' |
230 | 232 | var no_ads_default = |
231 | 233 | ".box:has(>style),div:has(>script),div:has(>.wwads-cn),.box:has(>.sidebar_compliance),div:has(>a>#DigitalOcean){display:none !important}" |
| 234 | + var side_nav_default = |
| 235 | + '#v2min_sideNav{--background-color: #000;--button-color: #aaa;--button-hover-color: #fff;--button-separator-color: #999;position:fixed;display:flex !important;bottom:0px;right:0px;background-color:var(--background-color);opacity:75%;border-top-left-radius:6px}#v2min_sideNav button{color:var(--button-color);font-size:18px;width:30px;height:30px;background-color:unset;border:none;position:relative}#v2min_sideNav button:hover{color:var(--button-hover-color)}#v2min_sideNav button:disabled{color:#778087;opacity:50%}#v2min_sideNav button::after{content:"";border-left:1px solid var(--button-separator-color);position:absolute;bottom:10px;right:-1px;width:1px;height:10px}#v2min_sideNav button:last-of-type::after{display:none}#v2min_sideNav button.fa-chevron-left,#v2min_sideNav button.fa-chevron-right,#v2min_sideNav button.fa-bell{font-size:14px}' |
232 | 236 | var sticky_header_default = |
233 | 237 | '#Top{position:fixed;top:0;width:100%;box-sizing:border-box}#Top .content{max-width:unset !important;width:100% !important}.site-nav .tools{flex:unset}.site-nav a[name=top]{margin-right:auto}#Wrapper::before{content:"";display:block;height:44px}#placeholder{height:38px}#Tabs{position:fixed;top:1px;padding:9px;border:none}#search-container{width:100px}#search-container:has(input:focus){width:300px}body:has(input:focus) #Tabs{display:none}@media only screen and (max-width: 1300px){.site-nav a[name=top]{visibility:hidden}}body{scroll-margin-top:44px}' |
234 | 238 | var content_default = |
235 | 239 | "#v2min_settings{position:fixed;top:10px;right:30px;min-width:250px;max-height:90%;overflow-y:auto;overflow-x:hidden;display:none;box-sizing:border-box;padding:10px 15px;background-color:#f3f3f3;z-index:100000;border-radius:5px;-webkit-box-shadow:0px 10px 39px 10px rgba(62,66,66,.22);-moz-box-shadow:0px 10px 39px 10px rgba(62,66,66,.22);box-shadow:0px 10px 39px 10px rgba(62,66,66,.22) !important}#v2min_settings h2{text-align:center;margin:5px 0 0;font-size:18px;font-weight:600;border:none}#v2min_settings footer{text-align:center;font-size:11px;margin:10px auto 0px}#v2min_settings footer a{color:#217dfc}#v2min_settings .option_groups{background-color:#fff;padding:6px 0 6px 15px;border-radius:10px;display:flex;flex-direction:column;margin:10px 0 0}#v2min_settings .option_groups .action{font-size:14px;border-top:1px solid #ccc;padding:6px 15px 6px 0;color:#217dfc;cursor:pointer}#v2min_settings .option_groups:nth-of-type(2){display:none}#v2min_settings .option_groups textarea{margin:10px 15px 10px 0;height:200px;width:300px;border:1px solid #a9a9a9}#v2min_settings .switch_option{display:flex;justify-content:space-between;align-items:center;border-top:1px solid #ccc;padding:6px 15px 6px 0;font-size:14px}#v2min_settings .switch_option:first-of-type,#v2min_settings .option_groups .action:first-of-type{border-top:none}#v2min_settings .container{--button-width: 51px;--button-height: 24px;--toggle-diameter: 20px;--color-off: #e9e9eb;--color-on: #34c759;width:var(--button-width);height:var(--button-height);position:relative}#v2min_settings input[type=checkbox]{opacity:0;width:0;height:0;position:absolute}#v2min_settings .switch{width:100%;height:100%;display:block;background-color:var(--color-off);border-radius:calc(var(--button-height)/2);cursor:pointer;transition:all .2s ease-out}#v2min_settings .slider{width:var(--toggle-diameter);height:var(--toggle-diameter);position:absolute;left:2px;top:calc(50% - var(--toggle-diameter)/2);border-radius:50%;background:#fff;box-shadow:0px 3px 8px rgba(0,0,0,.15),0px 3px 1px rgba(0,0,0,.06);transition:all .2s ease-out;cursor:pointer}#v2min_settings input[type=checkbox]:checked+.switch{background-color:var(--color-on)}#v2min_settings input[type=checkbox]:checked+.switch .slider{left:calc(var(--button-width) - var(--toggle-diameter) - 2px)}" |
| 240 | + function showSideNav() { |
| 241 | + if (!document.body) { |
| 242 | + return |
| 243 | + } |
| 244 | + if (!$("#v2min_sideNav")) { |
| 245 | + const sideNav = addElement(document.body, "div", { |
| 246 | + id: "v2min_sideNav", |
| 247 | + style: "display: none", |
| 248 | + }) |
| 249 | + addElement(sideNav, "button", { |
| 250 | + class: "fa fa-arrow-circle-up", |
| 251 | + title: "Back to the top", |
| 252 | + onclick() { |
| 253 | + window.scrollTo({ |
| 254 | + top: 0, |
| 255 | + behavior: "smooth", |
| 256 | + }) |
| 257 | + }, |
| 258 | + }) |
| 259 | + addElement(sideNav, "button", { |
| 260 | + class: "fa fa-comments", |
| 261 | + title: "Comments", |
| 262 | + disabled: |
| 263 | + location.href.includes("/t/") && $("#Main > div:nth-child(4)") |
| 264 | + ? void 0 |
| 265 | + : true, |
| 266 | + onclick() { |
| 267 | + window.scrollTo({ |
| 268 | + top: |
| 269 | + $("#Main > div:nth-child(4)").offsetTop - |
| 270 | + (getSettingsValue("stickyHeader") ? 44 : 0), |
| 271 | + behavior: "smooth", |
| 272 | + }) |
| 273 | + }, |
| 274 | + }) |
| 275 | + addElement(sideNav, "button", { |
| 276 | + class: "fa fa-edit", |
| 277 | + title: "Add comment", |
| 278 | + value: "AA", |
| 279 | + disabled: |
| 280 | + location.href.includes("/t/") && $("#reply_content") ? void 0 : true, |
| 281 | + onclick() { |
| 282 | + $("#reply_content").focus() |
| 283 | + }, |
| 284 | + }) |
| 285 | + addElement(sideNav, "button", { |
| 286 | + class: "fa fa-chevron-left", |
| 287 | + title: "Go to previous page", |
| 288 | + disabled: $('*[title="\u4E0A\u4E00\u9875"]') ? void 0 : true, |
| 289 | + onclick() { |
| 290 | + $('*[title="\u4E0A\u4E00\u9875"]').click() |
| 291 | + }, |
| 292 | + }) |
| 293 | + addElement(sideNav, "button", { |
| 294 | + class: "fa fa-chevron-right", |
| 295 | + title: "Go to next page", |
| 296 | + disabled: $('*[title="\u4E0B\u4E00\u9875"]') ? void 0 : true, |
| 297 | + onclick() { |
| 298 | + $('*[title="\u4E0B\u4E00\u9875"]').click() |
| 299 | + }, |
| 300 | + }) |
| 301 | + addElement(sideNav, "button", { |
| 302 | + class: "fa fa-bell", |
| 303 | + title: "Notifications", |
| 304 | + onclick() { |
| 305 | + location.href = "https://www.v2ex.com/notifications" |
| 306 | + }, |
| 307 | + }) |
| 308 | + addElement(sideNav, "button", { |
| 309 | + class: "fa fa-home", |
| 310 | + title: "Home", |
| 311 | + onclick() { |
| 312 | + location.href = "/" |
| 313 | + }, |
| 314 | + }) |
| 315 | + addElement(sideNav, "button", { |
| 316 | + class: "fa fa-cog", |
| 317 | + title: "Settings", |
| 318 | + onclick() { |
| 319 | + setTimeout(showSettings, 1) |
| 320 | + }, |
| 321 | + }) |
| 322 | + } |
| 323 | + } |
236 | 324 | function createSwitch(options = {}) { |
237 | 325 | const container = createElement("label", { class: "container" }) |
238 | 326 | const checkbox = createElement( |
|
254 | 342 | div.append(createSwitch(options)) |
255 | 343 | return div |
256 | 344 | } |
| 345 | + var config = { |
| 346 | + matches: ["https://*.v2ex.com/*", "https://v2hot.pipecraft.net/*"], |
| 347 | + } |
257 | 348 | var settingsTable = { |
258 | 349 | minimalist: { |
259 | 350 | title: "\u6781\u7B80\u98CE\u683C", |
|
271 | 362 | title: "\u589E\u5F3A\u663E\u793A\u8282\u70B9\u540D", |
272 | 363 | defaultValue: true, |
273 | 364 | }, |
| 365 | + showSideNav: { |
| 366 | + title: "\u663E\u793A\u5FEB\u6377\u6309\u94AE", |
| 367 | + defaultValue: true, |
| 368 | + }, |
274 | 369 | bodyBackgroundColor: { |
275 | 370 | title: "\u53BB\u9664\u9875\u9762\u80CC\u666F\u8272", |
276 | 371 | defaultValue: false, |
@@ -410,6 +505,7 @@ body #Wrapper.Night { |
410 | 505 | hidePinnedTopics: false, |
411 | 506 | hideProfilePhoto: false, |
412 | 507 | customStyle: false, |
| 508 | + showSideNav: false, |
413 | 509 | }) |
414 | 510 | }, |
415 | 511 | }) |
@@ -457,6 +553,10 @@ body #Wrapper.Night { |
457 | 553 | } |
458 | 554 | styles.push(hide_last_replier_default) |
459 | 555 | } |
| 556 | + if (getSettingsValue("showSideNav")) { |
| 557 | + styles.push(side_nav_default) |
| 558 | + showSideNav() |
| 559 | + } |
460 | 560 | if (getSettingsValue("hidePinnedTopics")) { |
461 | 561 | styles.push(`/* Hide pinned topics */ |
462 | 562 | #Main > div:nth-child(2) > div[style*="corner"] { |
@@ -491,6 +591,7 @@ body #Wrapper.Night { |
491 | 591 | } |
492 | 592 | #Tabs > a { |
493 | 593 | min-width: 3.5em; |
| 594 | + text-align: center; |
494 | 595 | } |
495 | 596 | `) |
496 | 597 | } |
|
0 commit comments