您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
PTT字型用微軟正黑體比較不傷眼
当前为
// ==UserScript== // @name PTT預設字型使用微軟正黑體 // @namespace https://github.com/livinginpurple // @version 2024.01.31.12 // @description PTT字型用微軟正黑體比較不傷眼 // @license WTFPL // @author livinginpurple // @match **://*.ptt.cc/* // @match **://disp.cc/b/* // @match **://disp.cc/m/* // @match **://disp.cc/ptt/* // @run-at document-end // @grant GM_getValue // @grant GM_setValue // @grant GM_registerMenuCommand // ==/UserScript== (() => { 'use strict'; console.log(`${GM_info.script.name} is loading.`); const fontSetting = 'fontSetting'; const options = [ { label: '微軟正黑體', value: 'Microsoft JhengHei' }, { label: 'Noto Sans CJK TC Regular', value: 'Noto Sans CJK TC Regular' }, { label: 'Noto Sans Mono CJK TC Regular', value: 'Noto Sans Mono CJK TC Regular' }, { label: 'Noto Sans TC', value: 'Noto Sans TC' }, { label: 'Noto Serif TC', value: 'Noto Serif TC' }, { label: '微軟雅黑體', value: 'Microsoft YaHei' } ]; changeFont(GM_getValue(fontSetting, options[0].value)); // 預設使用第一個選項 GM_registerMenuCommand('字型設定', openOptionsMenu); let container; function openOptionsMenu() { container = createContainer(); const label = createLabel('請選擇字型:'); const select = createSelect(options); select.value = GM_getValue(fontSetting, options[0].value); // 設定下拉選單的值 const button = createButton('Save', saveOptions); appendChildren(container, [label, select, button]); document.body.appendChild(container); } function saveOptions() { const selectedOption = container.querySelector('select').value; GM_setValue(fontSetting, selectedOption); changeFont(selectedOption); container.remove(); } function changeFont(font) { const fontSelector = location.hostname === 'disp.cc' ? 'body' : '.bbs-content'; $(fontSelector).css({ 'font-family': font }); console.log(`字型已切換成:${font}`); } function createContainer() { const container = document.createElement('div'); Object.assign(container.style, { position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)', padding: '20px', borderRadius: '10px', backgroundColor: '#fff', boxShadow: '0px 0px 10px rgba(0, 0, 0, 0.5)', zIndex: '9999', }); return container; } function createLabel(text) { const label = document.createElement('label'); Object.assign(label, { textContent: text, style: 'display: block; margin-bottom: 5px; font-size: 14px; font-weight: bold;', }); return label; } function createSelect(options) { const select = document.createElement('select'); Object.assign(select.style, { marginBottom: '10px', width: '100%', height: '30px', border: '1px solid #ccc', borderRadius: '5px', backgroundColor: '#fff', fontSize: '14px', color: '#333', padding: '5px', }); options.forEach(option => { const optionElement = document.createElement('option'); Object.assign(optionElement, { value: option.value, textContent: option.label, }); select.appendChild(optionElement); }); return select; } function createButton(text, clickHandler) { const button = document.createElement('button'); Object.assign(button, { textContent: text, style: 'width: 100%; height: 30px; border: none; border-radius: 5px; background-color: #007bff; color: #fff; font-size: 14px; cursor: pointer;', }); button.addEventListener('click', clickHandler); return button; } function appendChildren(parent, children) { children.forEach(child => parent.appendChild(child)); } console.log(`${GM_info.script.name} is running.`); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址