您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Inserts a true new line/line break/blank line when pressing Shift + Enter in an old interface Reddit textarea. Check out this post to learn more: https://old.reddit.com/r/help/comments/1vjfm9/how_do_i_insert_a_blank_line_between_2_lines_of/
// ==UserScript== // @name Insert true new line/line break/blank line in an old interface Reddit post by Shift + Enter // @author NWP // @description Inserts a true new line/line break/blank line when pressing Shift + Enter in an old interface Reddit textarea. Check out this post to learn more: https://old.reddit.com/r/help/comments/1vjfm9/how_do_i_insert_a_blank_line_between_2_lines_of/ // @namespace https://greasyfork.org/users/877912 // @version 0.1 // @license MIT // @match *://old.reddit.com/* // @grant none // ==/UserScript== (function() { 'use strict'; function adjustScroll(activeElement) { let lineHeight = parseFloat(window.getComputedStyle(activeElement).lineHeight); activeElement.scrollTop += lineHeight * 4; } document.addEventListener('keydown', function(event) { let activeElement = document.activeElement; if (activeElement && activeElement.tagName === 'TEXTAREA') { if (event.shiftKey && event.key === 'Enter') { event.preventDefault(); let cursorPos = activeElement.selectionStart; document.execCommand('insertText', false, "\n\n \n\n"); activeElement.selectionEnd = cursorPos + 10; adjustScroll(activeElement); } else if ((event.ctrlKey || event.metaKey) && (event.key === 'z' || event.key === 'Z')) { setTimeout(() => adjustScroll(activeElement), 0); } else if ((event.ctrlKey || event.metaKey) && (event.key === 'y' || event.key === 'Y')) { setTimeout(() => adjustScroll(activeElement), 0); } } }); })();