🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2025/12/24 05:48:59
🔄 下次更新时间:2025/12/24 06:48:59
手动刷新缓存

LeetCode Problem Copyer

复制Leetcode的题目的文本或HTML

Από την 28/06/2023. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         LeetCode Problem Copyer
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  复制Leetcode的题目的文本或HTML
// @author       You
// @match        https://leetcode.cn/problems/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=leetcode.cn
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
  ("use strict");
  var x = 100;
  var y = 20;
  var id = "dsafaafdsfss2112";

  function info(message) {
    let p = document.createElement("p");
    p.style.padding = "10px 20px";
    p.style.fontSize = "12px";
    p.style.display = "block";
    p.style.position = "absolute";
    p.style.left = `${x}px`;
    p.style.top = `${y}px`;
    p.style.border = "1px solid black";
    p.style.borderRadius = "3px";
    p.style.backgroundColor = "#FFF";
    p.innerText = message;
    document.body.appendChild(p);
    setTimeout(function () {
      document.body.removeChild(p);
    }, 1000);
  }

  function fnCopy(copyText) {
    navigator.clipboard
      .writeText(copyText)
      .then(() => {
        info("Copy Ok!");
      })
      .catch(() => {
        const input = document.createElement("input");
        document.body.appendChild(input);
        input.setAttribute("value", copyText);
        input.select();
        if (document.execCommand("copy")) {
          document.execCommand("copy");
        }
        document.body.removeChild(input);
        info("Copy Ok!");
      });
  }

  var createBtn = function (title, cb) {
    let mbtn = document.createElement("button");
    //mbtn.style.width = "40px";
    mbtn.classList.add("css-nabodd-Button");
    mbtn.style.height = "20px";
    mbtn.innerText = title;
    mbtn.style.padding='3px 5px';
    mbtn.style.border = "1px solid rgb(89, 89, 89)";
    mbtn.style.borderRadius = "3px";
    mbtn.style.zIndex = 999;
    mbtn.style.marginRight = "5px";
    mbtn.addEventListener("click", cb);
    return mbtn;
  };
  var createDiv = function () {
    let div = document.createElement("div");
    const htmlBtn = createBtn("CopyHtml", function (e) {
      x = e.clientX + 10;
      y = e.clientY + 10;
      fnCopy(
        document.querySelector('div[data-key="description-content"]').innerHTML
      );
    });
    const textBtn = createBtn("CopyText", function (e) {
      x = e.clientX + 10;
      y = e.clientY + 10;
      fnCopy(
        document.querySelector('div[data-key="description-content"]').innerText
      );
    });
    div.style.display='flex';
    div.appendChild(htmlBtn);
    div.appendChild(textBtn);
    div.id = id;
    return div;
  };

  function task() {
    if (document.getElementById(id)) {
      return true;
    }
    var _parent = document.querySelector('div[data-key="description-content"]').firstChild.firstChild.lastChild;
    if (_parent) {
      let div = createDiv();
      _parent.appendChild(div);
      return true;
    }
    return false;
  }

  var onceTask = setInterval(function () {
    try {
      task();
    } catch (e) {
      console.log("try..");
    }
  }, 1000);

})();