// ==UserScript== // @name CSDN Focus // @description CSDN, 脚本之家, 简书 无弹窗无广告无任何干扰, 自动展开文章和评论, 外链直达! CSDN独享黑暗模式🌚 // @version 1.9.8 // @author Finn // @namespace https://github.com/Germxu // @homepage https://github.com/Germxu/Scripts-for-TamperMonkey // @supportURL https://github.com/Germxu/Scripts-for-TamperMonkey/issues/new // @run-at document-start // @match blog.csdn.net/*/article/details/* // @match *.blog.csdn.net/article/details/* // @match www.jb51.net/article/* // @match www.jianshu.com/* // // @grant GM_setValue // @grant GM_getValue // @license MIT // @compatible Chrome 54+ // @compatible Safari Latest // @compatible Firefox Latest // @downloadURL none // ==/UserScript== (function () { 'use strict'; const finnWidth = GM_getValue('FinnData') && GM_getValue('FinnData').finnWidth || 1000; const csdn = `
`; const jb51 = ``; const jianshu = `` let h = document.documentElement, _Ds; let FinnData = new Proxy(GM_getValue('FinnData', {}), { set(target, key, val) { if (key === "dark") { val ? h.setAttribute("darkMode", true) : h.removeAttribute("darkMode"); } const B = Reflect.set(target, key, val); GM_setValue('FinnData', FinnData); return B; } }) if (location.host === "www.jb51.net") { _Ds = jb51 } else if (location.host === "www.jianshu.com") { _Ds = jianshu } else { _Ds = csdn; window.addEventListener("DOMContentLoaded", () => { mainBox.addEventListener('click', e => { let ev = e.target; if (ev.nodeName === 'A') { if (ev.host && !ev.host.includes("csdn")) { e.stopImmediatePropagation(); window.open(ev.href); e.preventDefault(); } } }, true); $("#darkBtn").click(() => { FinnData.dark = !FinnData.dark }) $("#FinnTop").click(() => { $("body,html").animate({ scrollTop: 0 }, 300) }); mainBox.addEventListener("mousedown", e => { if (e.target !== mainBox) return; let startX = e.clientX, offsetWidth = mainBox.offsetWidth; const maxSize = window.innerWidth * 0.8; mainBox.style.userSelect = "none"; e.stopPropagation(); document.onmousemove = e => { let endX = e.clientX; let moveLen = (startX / maxSize < 0.5) ? startX - endX : endX - startX; let l = offsetWidth + moveLen * 2 - 20; l = l < 888 ? 888 : l > maxSize ? maxSize : l; FinnData.finnWidth = l; h.style.setProperty('--finn-width', l + "px"); } document.onmouseup = () => { mainBox.style.userSelect = "auto"; document.onmousemove = null; document.onmouseup = null; } }, true) }) } function ins() { h = h||document.documentElement; h.insertAdjacentHTML('afterbegin', _Ds); FinnData.dark && h.setAttribute("darkMode", true); } if (!h) { let OB = new MutationObserver(ins); OB.observe(document, { childList: true }) } else { ins() } })();