您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds <br> before and after <code> tags on FreeCodeCamp
当前为
// ==UserScript== // @name Add <br> around <code> tags on FreeCodeCamp // @namespace http://tampermonkey.net/ // @version 0.2 // @description Adds <br> before and after <code> tags on FreeCodeCamp // @author Geromet // @match https://www.freecodecamp.org/learn/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; function addLineBreaks() { const codeElements = document.getElementsByTagName('code'); for (const codeElement of codeElements) { const prevSibling = codeElement.previousSibling; const nextSibling = codeElement.nextSibling; if (prevSibling && prevSibling.tagName === 'BR' && nextSibling && nextSibling.tagName === 'BR') { continue; } const lineBreakBefore = document.createElement('br'); codeElement.parentNode.insertBefore(lineBreakBefore, codeElement); const lineBreakAfter = document.createElement('br'); codeElement.parentNode.insertBefore(lineBreakAfter, codeElement.nextSibling); } clearInterval(intervalId); resizeWindow(); setTimeout(restoreWindowSize, 1000); } function resizeWindow() { window.resizeTo(window.innerWidth - 420, window.innerHeight); } function restoreWindowSize() { window.resizeTo(window.innerWidth + 420, window.innerHeight); } const intervalId = setInterval(function() { const codeElements = document.getElementsByTagName('code'); if (codeElements.length > 0) { addLineBreaks(); } }, 100); })();