// ==UserScript== // @name ▲V2EX Polish - 体验更现代化的 V2EX 🟢 // @namespace LeoKu(https://leoku.top) // @version 1.5.0 // @description 一款专为 V2EX 用户设计的浏览器插件,提供了丰富的扩展功能,让原生页面焕然一新!✨ // @author LeoKu // @match https://*.v2ex.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=v2ex.com // @run-at document-start // @grant GM_addStyle // @license MIT // @downloadURL none // ==/UserScript== "use strict"; var __getOwnPropNames = Object.getOwnPropertyNames; var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/createElement.js var createElement, createElement$1; var init_createElement = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/createElement.js"() { createElement = (tag, attrs, children = []) => { const element = document.createElementNS("http://www.w3.org/2000/svg", tag); Object.keys(attrs).forEach((name) => { element.setAttribute(name, String(attrs[name])); }); if (children.length) { children.forEach((child) => { const childElement = createElement(...child); element.appendChild(childElement); }); } return element; }; createElement$1 = ([tag, attrs, children]) => createElement(tag, attrs, children); } }); // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/replaceElement.js var getAttrs, getClassNames, combineClassNames, toPascalCase, replaceElement; var init_replaceElement = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/replaceElement.js"() { init_createElement(); getAttrs = (element) => Array.from(element.attributes).reduce((attrs, attr) => { attrs[attr.name] = attr.value; return attrs; }, {}); getClassNames = (attrs) => { if (typeof attrs === "string") return attrs; if (!attrs || !attrs.class) return ""; if (attrs.class && typeof attrs.class === "string") { return attrs.class.split(" "); } if (attrs.class && Array.isArray(attrs.class)) { return attrs.class; } return ""; }; combineClassNames = (arrayOfClassnames) => { const classNameArray = arrayOfClassnames.flatMap(getClassNames); return classNameArray.map((classItem) => classItem.trim()).filter(Boolean).filter((value, index, self) => self.indexOf(value) === index).join(" "); }; toPascalCase = (string) => string.replace(/(\w)(\w*)(_|-|\s*)/g, (g0, g1, g2) => g1.toUpperCase() + g2.toLowerCase()); replaceElement = (element, { nameAttr, icons, attrs }) => { const iconName = element.getAttribute(nameAttr); if (iconName == null) return; const ComponentName = toPascalCase(iconName); const iconNode = icons[ComponentName]; if (!iconNode) { return console.warn( `${element.outerHTML} icon name was not found in the provided icons object.` ); } const elementAttrs = getAttrs(element); const [tag, iconAttributes, children] = iconNode; const iconAttrs = { ...iconAttributes, "data-lucide": iconName, ...attrs, ...elementAttrs }; const classNames = combineClassNames(["lucide", `lucide-${iconName}`, elementAttrs, attrs]); if (classNames) { Object.assign(iconAttrs, { class: classNames }); } const svgElement = createElement$1([tag, iconAttrs, children]); return element.parentNode?.replaceChild(svgElement, element); }; } }); // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/defaultAttributes.js var defaultAttributes; var init_defaultAttributes = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/defaultAttributes.js"() { defaultAttributes = { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": 2, "stroke-linecap": "round", "stroke-linejoin": "round" }; } }); // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/book-open-check.js var BookOpenCheck; var init_book_open_check = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/book-open-check.js"() { init_defaultAttributes(); BookOpenCheck = [ "svg", defaultAttributes, [ ["path", { d: "M8 3H2v15h7c1.7 0 3 1.3 3 3V7c0-2.2-1.8-4-4-4Z" }], ["path", { d: "m16 12 2 2 4-4" }], ["path", { d: "M22 6V3h-6c-2.2 0-4 1.8-4 4v14c0-1.7 1.3-3 3-3h7v-2.3" }] ] ]; } }); // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/chevrons-up.js var ChevronsUp; var init_chevrons_up = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/chevrons-up.js"() { init_defaultAttributes(); ChevronsUp = [ "svg", defaultAttributes, [ ["polyline", { points: "17 11 12 6 7 11" }], ["polyline", { points: "17 18 12 13 7 18" }] ] ]; } }); // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/clock-4.js var Clock4; var init_clock_4 = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/clock-4.js"() { init_defaultAttributes(); Clock4 = [ "svg", defaultAttributes, [ ["circle", { cx: "12", cy: "12", r: "10" }], ["polyline", { points: "12 6 12 12 16 14" }] ] ]; } }); // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/eye-off.js var EyeOff; var init_eye_off = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/eye-off.js"() { init_defaultAttributes(); EyeOff = [ "svg", defaultAttributes, [ ["path", { d: "M9.88 9.88a3 3 0 1 0 4.24 4.24" }], [ "path", { d: "M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68" } ], [ "path", { d: "M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61" } ], ["line", { x1: "2", x2: "22", y1: "2", y2: "22" }] ] ]; } }); // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/heart.js var Heart; var init_heart = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/heart.js"() { init_defaultAttributes(); Heart = [ "svg", defaultAttributes, [ [ "path", { d: "M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z" } ] ] ]; } }); // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/message-square-plus.js var MessageSquarePlus; var init_message_square_plus = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/message-square-plus.js"() { init_defaultAttributes(); MessageSquarePlus = [ "svg", defaultAttributes, [ [ "path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" } ], ["line", { x1: "9", x2: "15", y1: "10", y2: "10" }], ["line", { x1: "12", x2: "12", y1: "7", y2: "13" }] ] ]; } }); // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/message-square.js var MessageSquare; var init_message_square = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/message-square.js"() { init_defaultAttributes(); MessageSquare = [ "svg", defaultAttributes, [ [ "path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" } ] ] ]; } }); // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/moon.js var Moon; var init_moon = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/moon.js"() { init_defaultAttributes(); Moon = [ "svg", defaultAttributes, [["path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z" }]] ]; } }); // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/package-plus.js var PackagePlus; var init_package_plus = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/package-plus.js"() { init_defaultAttributes(); PackagePlus = [ "svg", defaultAttributes, [ ["path", { d: "M16 16h6" }], ["path", { d: "M19 13v6" }], [ "path", { d: "M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14" } ], ["path", { d: "M16.5 9.4 7.55 4.24" }], ["polyline", { points: "3.29 7 12 12 20.71 7" }], ["line", { x1: "12", x2: "12", y1: "22", y2: "12" }] ] ]; } }); // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/smile.js var Smile; var init_smile = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/smile.js"() { init_defaultAttributes(); Smile = [ "svg", defaultAttributes, [ ["circle", { cx: "12", cy: "12", r: "10" }], ["path", { d: "M8 14s1.5 2 4 2 4-2 4-2" }], ["line", { x1: "9", x2: "9.01", y1: "9", y2: "9" }], ["line", { x1: "15", x2: "15.01", y1: "9", y2: "9" }] ] ]; } }); // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/star.js var Star; var init_star = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/star.js"() { init_defaultAttributes(); Star = [ "svg", defaultAttributes, [ [ "polygon", { points: "12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" } ] ] ]; } }); // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/sun.js var Sun; var init_sun = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/sun.js"() { init_defaultAttributes(); Sun = [ "svg", defaultAttributes, [ ["circle", { cx: "12", cy: "12", r: "4" }], ["path", { d: "M12 2v2" }], ["path", { d: "M12 20v2" }], ["path", { d: "m4.93 4.93 1.41 1.41" }], ["path", { d: "m17.66 17.66 1.41 1.41" }], ["path", { d: "M2 12h2" }], ["path", { d: "M20 12h2" }], ["path", { d: "m6.34 17.66-1.41 1.41" }], ["path", { d: "m19.07 4.93-1.41 1.41" }] ] ]; } }); // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/twitter.js var Twitter; var init_twitter = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/icons/twitter.js"() { init_defaultAttributes(); Twitter = [ "svg", defaultAttributes, [ [ "path", { d: "M22 4s-.7 2.1-2 3.4c1.6 10-9.4 17.3-18 11.6 2.2.1 4.4-.6 6-2C3 15.5.5 9.6 3 5c2.2 2.6 5.6 4.1 9 4-.9-4.2 4-6.6 7-3.8 1.1 0 3-1.2 3-1.2z" } ] ] ]; } }); // node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/lucide.js var createIcons; var init_lucide = __esm({ "node_modules/.pnpm/lucide@0.258.0/node_modules/lucide/dist/esm/lucide.js"() { init_replaceElement(); init_createElement(); init_book_open_check(); init_chevrons_up(); init_clock_4(); init_eye_off(); init_heart(); init_message_square_plus(); init_message_square(); init_moon(); init_package_plus(); init_smile(); init_star(); init_sun(); init_twitter(); createIcons = ({ icons = {}, nameAttr = "data-lucide", attrs = {} } = {}) => { if (!Object.values(icons).length) { throw new Error( "Please provide an icons object.\nIf you want to use all the icons you can import it like:\n `import { createIcons, icons } from 'lucide';\nlucide.createIcons({icons});`" ); } if (typeof document === "undefined") { throw new Error("`createIcons()` only works in a browser environment."); } const elementsToReplace = document.querySelectorAll(`[${nameAttr}]`); Array.from(elementsToReplace).forEach( (element) => replaceElement(element, { nameAttr, icons, attrs }) ); if (nameAttr === "data-lucide") { const deprecatedElements = document.querySelectorAll("[icon-name]"); if (deprecatedElements.length > 0) { console.warn("[Lucide] Some icons were found with the now deprecated icon-name attribute. These will still be replaced for backwards compatibility, but will no longer be supported in v1.0 and you should switch to data-lucide"); Array.from(deprecatedElements).forEach( (element) => replaceElement(element, { nameAttr: "icon-name", icons, attrs }) ); } } }; } }); // src/constants.ts var EXTENSION_NAME, emoticons, READABLE_CONTENT_HEIGHT, MAX_CONTENT_HEIGHT, READING_CONTENT_LIMIT, dataExpiryTime, imgurClientIdPool, defaultOptions; var init_constants = __esm({ "src/constants.ts"() { "use strict"; EXTENSION_NAME = "V2EX_Polish"; emoticons = [ { title: "\u5C0F\u9EC4\u8138", list: [ "\u{1F600}", "\u{1F601}", "\u{1F602}", "\u{1F923}", "\u{1F605}", "\u{1F60A}", "\u{1F60B}", "\u{1F618}", "\u{1F970}", "\u{1F617}", "\u{1F929}", "\u{1F914}", "\u{1F928}", "\u{1F610}", "\u{1F611}", "\u{1F644}", "\u{1F60F}", "\u{1F62A}", "\u{1F62B}", "\u{1F971}", "\u{1F61C}", "\u{1F612}", "\u{1F614}", "\u{1F628}", "\u{1F630}", "\u{1F631}", "\u{1F975}", "\u{1F621}", "\u{1F973}", "\u{1F97A}", "\u{1F92D}", "\u{1F9D0}", "\u{1F60E}", "\u{1F913}", "\u{1F62D}", "\u{1F911}", "\u{1F92E}" ] }, { title: "\u624B\u52BF", list: [ "\u{1F64B}", "\u{1F64E}", "\u{1F645}", "\u{1F647}", "\u{1F937}", "\u{1F90F}", "\u{1F449}", "\u270C\uFE0F", "\u{1F918}", "\u{1F919}", "\u{1F44C}", "\u{1F90C}", "\u{1F44D}", "\u{1F44E}", "\u{1F44B}", "\u{1F91D}", "\u{1F64F}", "\u{1F44F}" ] }, { title: "\u5E86\u795D", list: ["\u2728", "\u{1F389}", "\u{1F38A}"] }, { title: "\u5176\u4ED6", list: ["\u{1F47B}", "\u{1F921}", "\u{1F414}", "\u{1F440}", "\u{1F4A9}", "\u{1F434}", "\u{1F984}", "\u{1F427}", "\u{1F436}", "\u{1F412}", "\u{1F648}", "\u{1F649}", "\u{1F64A}", "\u{1F435}"] } ]; READABLE_CONTENT_HEIGHT = 250; MAX_CONTENT_HEIGHT = 550; READING_CONTENT_LIMIT = 150; dataExpiryTime = 60 * 60 * 1e3; imgurClientIdPool = [ "3107b9ef8b316f3", // 以下 Client ID 来自「V2EX Plus」 "442b04f26eefc8a", "59cfebe717c09e4", "60605aad4a62882", "6c65ab1d3f5452a", "83e123737849aa9", "9311f6be1c10160", "c4a4a563f698595", "81be04b9e4a08ce" ]; defaultOptions = { openInNewTab: false, autoCheckIn: { enabled: true }, theme: { autoSwitch: false }, reply: { preload: "off" }, replyContent: { autoFold: true }, nestedReply: { display: "indent", multipleInsideOne: "nested" } }; } }); // src/icons.ts var iconLoading, iconLogo, iconChromeWebStore, iconGitHub; var init_icons = __esm({ "src/icons.ts"() { "use strict"; iconLoading = ``; iconLogo = ``; iconChromeWebStore = ``; iconGitHub = ``; } }); // src/components/toast.ts function createToast(props) { const { message, duration = 3e3 } = props; const $existTosat = $(".v2p-toast"); if ($existTosat.length > 0) { $existTosat.remove(); } const $toast = $(`
\u8BE5\u4E3B\u9898\u6CA1\u6709\u6B63\u6587\u5185\u5BB9