Skip to content

Instantly share code, notes, and snippets.

@julenwang
Last active December 10, 2021 08:26
Show Gist options
  • Save julenwang/2522b72802a18e699d10b26886357f73 to your computer and use it in GitHub Desktop.
Save julenwang/2522b72802a18e699d10b26886357f73 to your computer and use it in GitHub Desktop.
删除 leetcode 题解页的额外元素,用于网页截图
// ==UserScript==
// @name deleteLeetcodeNodes.js
// @namespace manual
// @match https://leetcode-cn.com/*
// @version 0.3
// @author Julen
// @description 2021/12/10 下午3:30:44
// @grant GM_registerMenuCommand
// ==/UserScript==
(function(){
function omitNodes(classes) {
Array.from(document.querySelectorAll("*"))
.filter((node) => classes.some((pattern) => pattern.test(node.className)))
.forEach((node) => {
node.remove();
});
}
GM_registerMenuCommand("leetcode删除元素以截图", () => {
omitNodes([/HeaderCn/,/OperationsWrapper/,/DiscussWrapper/,/bottom-right/,/BarContainer/]);
});
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment