Greasy Fork is available in English.
用于美化豆瓣小组界面
当前为
// ==UserScript==
// @name 豆瓣界面优化
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 用于美化豆瓣小组界面
// @license BSD-3
// @author AnyDoor
// @match https://www.douban.com/group/*
// @icon https://img3.doubanio.com/dae/accounts/resources/3e96b44/shire/assets/nav_doubanapp_6.png
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// ==/UserScript==
(function() {
'use strict';
// Your code here...
//抽奖标签样式 背景色为紫色 #7c4df0
$("head").append("<style> .DrawTag{font-size: 12px;display: inline-block;color: white;margin-right: 4px;background-color: #7c4df0;border: 1px solid rgba(0,0,0,0.1);padding: 1px 3px;border-radius: 2px;line-height: 18px;}</style>")
const TitleObject = document.querySelectorAll("td[class='title']");
//巡逻每一个标题
TitleObject.forEach(to =>{
var TitleLen = to.children.length;
//过滤已经设置为精华的帖子 设置为精华置顶时元素长度为3
if(TitleLen <=2 ){
//读取该标题的文本
var TitleStr = to.children[0].title
//构建抽奖标签
var DrawTag = document.createElement("span");
var DrawTag_text = document.createTextNode("抽奖");
DrawTag.className = 'DrawTag';
DrawTag.textContent = "抽奖";
//判断标题是否包含抽奖关键词
if(TitleStr.includes('抽奖')){
//在标题前插入抽奖标签
to.insertBefore(DrawTag,to.children[0]);
}
}
});
// let id=GM_registerMenuCommand ("测试(不要点击)", function(){
// //alert('菜单点击');
// //GM_unregisterMenuCommand(id);//删除菜单
// }, "h");
})();