绿色纯净版CSDN-持续更新

绿色纯净版CSDN-持续更新,现支持🔥免登录复制🔥沉浸式阅读

当前为 2024-01-15 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         绿色纯净版CSDN-持续更新
// @namespace    CSDNGreen
// @version      0.0.52
// @description  绿色纯净版CSDN-持续更新,现支持🔥免登录复制🔥沉浸式阅读
// @author       LiuHangShu
// @include      *://*.csdn.net/*
// @license      AGPL-3.0-or-later
// @note         24-1-11 0.0.51 jq-err
// @note         24-1-15 0.0.52 沉浸式阅读
// ==/UserScript==

const version = " 0.0.52";

function copy() {
  try {
    if (typeof $ == "undefined") {
      console.log("jQuery is not loaded");
      return;
    }
    // 免登录复制
    $(".hljs-button").removeClass("signin");
    $(".hljs-button").addClass("{2}");
    $(".hljs-button").attr("data-title", "免登录复制");
    $(".hljs-button").attr(
      "onclick",
      "hljs.copyCode(event);setTimeout(function(){$('.hljs-button').attr('data-title', '免登录复制');},3500);"
    );
    $("#content_views").unbind("copy");
    // 去除剪贴板劫持
    $("code").attr("onclick", "mdcp.copyCode(event)");
    try {
      Object.defineProperty(window, "articleType", {
        value: 0,
        writable: false,
        configurable: false,
      });
    } catch (err) {}
    try {
      unsafeWindow.csdn.copyright.init("", "", "");
    } catch (_err) {}
    console.log("copy fn run success");
  } catch (err) {
    $$("*").forEach((item) => {
      item.oncopy = (e) => e.stopPropagation();
    });
    console.log("copy fn run error");
  }
}

function fullScreen() {
  $(".blog_container_aside").remove();
  $("main").css("width", "100%");
  $(".csdn-side-toolbar").remove();
  console.log("fullScreen fn run success");
}

function remove() {
  // 登录
  const loginModal = $(".passport-login-container");
  // 红包
  const redpackModal = $("#csdn-redpack");
  const iframe = $("iframe");
  const toolBarBox = $(".more-toolbox-new");
  const blogHuaweiyunAdvert = $("#blogHuaweiyunAdvert");
  const blogColumnPayAdvert = $("#blogColumnPayAdvert");
  const recommendNps = $("#recommendNps");
  const recommendBox = $(".recommend-box");
  const articleInfoBox = $(".article-info-box");
  const adverts1 = $(".J_adv");
  const adverts2 = $(".feed-fix-box");

  const elements = [
    loginModal,
    redpackModal,
    iframe,
    toolBarBox,
    blogHuaweiyunAdvert,
    blogColumnPayAdvert,
    adverts1,
    adverts2,
    recommendNps,
    recommendBox,
    articleInfoBox,
  ];

  let timer = setInterval(function () {
    const clear = elements.every((item) => !item.length);
    if (clear) {
      clearInterval(timer);
    }
    elements.forEach((item) => {
      item && item.remove();
    });
  }, 500);
}

// #mainBox #csdn-copyright-footer

function main() {
  copy();
  fullScreen();
  remove();
  console.log("正在运行");
}
main();