掘金文章详情页,添加文章等级标注

掘金文章详情页,添加文章等级标注!

当前为 2021-03-31 提交的版本,查看 最新版本

// ==UserScript==
// @name         掘金文章详情页,添加文章等级标注
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  掘金文章详情页,添加文章等级标注!
// @author       You
// @include     https://juejin.cn/post/*
// @grant        none
// ==/UserScript==

(function () {
  "use strict";

  let viewData = document
    .querySelector(".views-count")
    .innerText.replace("阅读 ", "");
  let likeData = document.querySelector(".like-btn").getAttribute("badge");
  let level = Math.floor((likeData * 100) / viewData);
  var newNode = document.createElement("div");
  newNode.setAttribute("class", "panel-btn like-adjust");
  newNode.innerText = level;
  newNode.style.color = "#ffffff";
  newNode.style.backgroundColor = `rgba(0, 127, 255, ${level / 10})`;
  newNode.style.lineHeight = "36px";
  newNode.style.textAlign = "center";
  newNode.style.fontWeight = "bold";
  newNode.style.borderRadius = "50%";
  newNode.style.marginBottom = ".75rem";
  newNode.style.fontSize = "18px";
  let node = document.querySelector(".article-suspended-panel");
  node.insertBefore(newNode, node.childNodes[0]);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址