您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
change default settings for the github editor
当前为
// ==UserScript== // @name GitHub Editor - Change Default Settings // @namespace https://greatest.deepsurf.us/users/649 // @version 1.1.10 // @description change default settings for the github editor // @author Adrien Pyke // @match *://github.com/*/new/* // @match *://github.com/*/edit/* // @grant GM_getValue // @grant GM_setValue // @grant GM_registerMenuCommand // @require https://cdn.rawgit.com/kufii/My-UserScripts/f7657850f1c8c356c8a4be0977102c28e09f5740/libs/gm_config.js // @require https://cdn.rawgit.com/fuzetsu/userscripts/477063e939b9658b64d2f91878da20a7f831d98b/wait-for-elements/wait-for-elements.js // ==/UserScript== (() => { 'use strict'; const Config = GM_config([ { key: 'indentMode', label: 'Indent mode', default: 'tab', type: 'dropdown', values: [ { value: 'space', text: 'Spaces' }, { value: 'tab', text: 'Tabs' } ] }, { key: 'indentWidth', label: 'Indent size', default: 4, type: 'dropdown', values: [2, 4, 8] }, { key: 'wrapMode', label: 'Line wrap mode', default: 'off', type: 'dropdown', values: [ { value: 'off', text: 'No wrap' }, { value: 'on', text: 'Soft wrap' } ] } ]); const updateDropdown = function(dropdown, value) { dropdown.value = value; let evt = document.createEvent('HTMLEvents'); evt.initEvent('change', false, true); dropdown.dispatchEvent(evt); }; const applySettings = function(cfg) { let indentMode = document.querySelector('.js-code-indent-mode'); let indentWidth = document.querySelector('.js-code-indent-width'); let wrapMode = document.querySelector('.js-code-wrap-mode'); if (location.href.match(/^https?:\/\/github.com\/[^/]*\/[^/]*\/new\/.*/)) { // new file updateDropdown(indentMode, cfg.indentMode); updateDropdown(indentWidth, cfg.indentWidth); updateDropdown(wrapMode, cfg.wrapMode); } else if (location.href.match(/^https?:\/\/github.com\/[^/]*\/[^/]*\/edit\/.*/)) { // edit file // if the file is using space indentation we don't want to change it if (indentMode.value === 'tab') { updateDropdown(indentWidth, cfg.indentWidth); } updateDropdown(wrapMode, cfg.wrapMode); } }; GM_registerMenuCommand('GitHub Editor Settings', Config.setup); let settings = Config.load(); waitForElems({ sel: '.CodeMirror-code', onmatch() { applySettings(settings); } }); })();