Greasy Fork is available in English.
去除leetcode上烦人的复制小尾巴,自动开启差别比对(搬运自symant233作者的Beautify插件,对其功能进行了精简)。
// ==UserScript== // @name 🔥净化LeetCode复制内容、自动开启差别对比🔥 // @namespace com.zhaolei // @require https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js // @version 0.2 // @description 去除leetcode上烦人的复制小尾巴,自动开启差别比对(搬运自symant233作者的Beautify插件,对其功能进行了精简)。 // @author zhaolei // @match *://leetcode-cn.com/* // @icon https://www.google.com/s2/favicons?domain=tampermonkey.net // @license GPL-3.0 // @grant none // ==/UserScript== (function() { 'use strict'; if (!$) { var $ = window.jQuery; } function listeningCopyEvent() { self.addEventListener('copy', (e) => { const selection = document.getSelection() if (selection.toString() !== "") { e.preventDefault() e.clipboardData.setData('text', selection.toString()) } }) } listeningCopyEvent() function enableDiff () { const btn = document.querySelector('label[class*="Label-StyledSwitch"]'); if (btn && !btn.getAttribute('beautify-data')) { btn.setAttribute('beautify-data', true); btn.click(); } } setTimeout(() => { $('div[class*=second-section-container] > div:last-child button').click(); new Promise(resolve => { const container = document.querySelector('div[class*="CodeAreaContainer"]'); if (container) { new MutationObserver((mutationList) => { mutationList.forEach((mutation) => { if (mutation.oldValue) enableDiff(); }); }).observe(container, { attributes: true, attributeOldValue: true, subtree: true, }); } resolve(); }); }, 2600); })();