贴吧上屏蔽某些脑瘫的贴子
// ==UserScript==
// @name 贴吧上屏蔽某些脑瘫的贴子
// @namespace http://tampermonkey.net/
// @version 2024-04-28
// @description try to take over the world!
// @author YOU
// @match https://tieba.baidu.com/f?kw=%E9%80%86%E6%B0%B4%E5%AF%92ol*
// @icon https://www.google.com/s2/favicons?sz=64&domain=baidu.com
// @grant none
// ==/UserScript==
(function () {
'use strict';
const forbidURL = "https://tieba.baidu.com/tbmall/mymall?tab=forbid";
fetch(forbidURL, {
method: "GET",
headers: {
'Cookie': document.cookie
}
}).then(rsp => {
if (rsp.ok) {
return rsp.text();
} else {
throw new Error("访问异常");
}
}).then(data => {
const forbidIds = []
const parser = new DOMParser();
const doc = parser.parseFromString(data, "text/html");
const forbidLinks = doc.querySelectorAll("#my-forbid-speech-wrapper > ul > li.media-horizontal > a");
for (const link of forbidLinks) {
const dataField = JSON.parse(link.getAttribute("data-field"));
forbidIds.push(dataField.userId);
}
window.addEventListener('load', function () {
const thread_list = document.querySelectorAll("#thread_list > li");
thread_list.forEach(function (item) {
const nameElement = item.querySelector("div > div.col2_right.j_threadlist_li_right > div.threadlist_lz.clearfix > div.threadlist_author.pull_right > span.tb_icon_author > span.frs-author-name-wrap > a");
const userIdElement = item.querySelector("div > div.col2_right.j_threadlist_li_right > div.threadlist_lz.clearfix > div.threadlist_author.pull_right > span.tb_icon_author");
if (nameElement) {
const userId = userIdElement.getAttribute("data-field");
for (const id of forbidIds) {
if (userId.includes(id)) {
const targetTitle = item.querySelector("div > div.col2_right.j_threadlist_li_right > div.threadlist_lz.clearfix > div.threadlist_title.pull_left.j_th_tit > a").textContent;
console.log("找到一个目标: " + id + " >> " + nameElement.textContent);
console.log("目标标题: " + targetTitle);
item.remove();
break;
}
}
}
});
});
}).catch(e => console.error(e));
})();
贴吧上屏蔽某些脑瘫的楼层回复内容
// ==UserScript==
// @name 贴吧上屏蔽某些脑瘫的楼层回复内容
// @namespace http://tampermonkey.net/
// @version 2024-04-28
// @description try to take over the world!
// @author You
// @match https://tieba.baidu.com/p/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=baidu.com
// @grant none
// ==/UserScript==
(function () {
'use strict';
const forbidURL = "https://tieba.baidu.com/tbmall/mymall?tab=forbid";
fetch(forbidURL, {
method: "GET",
headers: {
'Cookie': document.cookie
}
}).then(rsp => {
if (rsp.ok) {
return rsp.text();
} else {
throw new Error("访问异常");
}
}).then(data => {
const forbidIds = []
const parser = new DOMParser();
const doc = parser.parseFromString(data, "text/html");
const forbidLinks = doc.querySelectorAll("#my-forbid-speech-wrapper > ul > li.media-horizontal > a");
for (const link of forbidLinks) {
const dataField = JSON.parse(link.getAttribute("data-field"));
forbidIds.push(dataField.userId);
}
window.addEventListener('load', function () {
const thread_list = document.querySelectorAll("#j_p_postlist > div.l_post");
thread_list.forEach(function (item) {
const nameElement = item.querySelector("div.d_author > ul > li.d_name > a");
const userIdElement = item.querySelector("div.d_author > ul > li.d_name")
if (nameElement) {
const userId = userIdElement.getAttribute("data-field");
for (const id of forbidIds) {
if (userId.includes(id)) {
const content = item.querySelector("div.d_post_content_main > div.p_content div.j_d_post_content").textContent;
console.log("找到一个目标: " + id + " >> " + nameElement.textContent);
console.log("目标楼层回复内容: " + content);
item.remove();
break;
}
}
}
});
});
}).catch(e => console.error(e));
})();
藏宝阁补全
// ==UserScript==
// @name 逆水寒藏宝阁商品补全
// @namespace http://tampermonkey.net/
// @version 2024-06-03
// @description try to take over the world!
// @author YOU
// @match https://n.cbg.163.com/cbg/query.py*
// @run-at document-end
// @icon https://www.google.com/s2/favicons?sz=64&domain=baidu.com
// @grant none
// ==/UserScript==
(function () {
'use strict';
function getUrlParams(url) {
let params = {};
let parser = new URL(url);
let queryString = parser.search.slice(1).split('&');
queryString.forEach(function (param) {
let pair = param.split('=');
params[pair[0]] = decodeURIComponent(pair[1]);
});
return params;
}
let params = getUrlParams(window.location.href);
let requiredParams = {
// 'serverid': '159',
'act': 'search_role',
'kindid': '13'
};
let allParamsPresent = Object.keys(requiredParams).every(key => params[key] === requiredParams[key]);
if (allParamsPresent) {
console.log("逆水寒藏宝阁商品补全油猴脚本:All required parameters are present.");
const xiangrui = document.querySelector("#xiangrui_tags_list2");
for (const item of xiangrui.getElementsByClassName("select-item")) {
if (item.innerHTML.includes("流光溯")) {
item.innerHTML = item.innerHTML.replace("流光溯", "流光溯.双人");
item.setAttribute("data-val", item.getAttribute("data-val").replace("流光溯", "流光溯.双人"));
break;
}
}
const xiangruiList = document.querySelector("#xiangrui_tags_list3");
const qhxy = document.createElement("li");
qhxy.className = "select-item";
qhxy.setAttribute("data-val", "轻鸿雪羽")
qhxy.innerHTML = "轻鸿雪羽";
xiangruiList.appendChild(qhxy);
const arms = document.querySelector("#arms_clothes_series");
const li3 = document.createElement("li");
li3.className = "select-item";
li3.setAttribute("data-val", "霆雷惊夜")
li3.innerHTML = "霆雷惊夜";
arms.appendChild(li3);
// 分析当前路径参数
const url = window.location.href;
const rootURL = url.split("?")[0];
const paramObj = {};
const params = url.split("?")[1].split("&");
params.forEach(kv => {
const kvArray = kv.split("=");
paramObj[kvArray[0]] = decodeURIComponent(kvArray[1]);
});
// 补全自己额外新增的没有的选项的选中状态: 车架祥瑞
if ("xiangrui_name1" in paramObj) {
const xiangrui1List = document.querySelectorAll("#xiangrui_tags_list1 > li.select-item");
for (const item of xiangrui1List) {
const xrName = item.getAttribute("data-val");
if (paramObj["xiangrui_name1"].indexOf(xrName) !== -1 && item.className.indexOf("select-item_on") === -1) {
item.className += " select-item_on";
}
}
}
// 补全自己额外新增的没有的选项的选中状态: 陆行祥瑞
if ("xiangrui_name2" in paramObj) {
const xiangrui2List = document.querySelectorAll("#xiangrui_tags_list2 > li.select-item");
for (const item of xiangrui2List) {
const xrName = item.getAttribute("data-val");
if (paramObj["xiangrui_name2"].indexOf(xrName) !== -1 && item.className.indexOf("select-item_on") === -1) {
item.className += " select-item_on";
}
}
}
// 补全自己额外新增的没有的选项的选中状态: 飞行祥瑞
if ("xiangrui_name3" in paramObj) {
const xiangrui3List = document.querySelectorAll("#xiangrui_tags_list3 > li.select-item");
for (const item of xiangrui3List) {
const xrName = item.getAttribute("data-val");
if (paramObj["xiangrui_name3"].indexOf(xrName) !== -1 && item.className.indexOf("select-item_on") === -1) {
item.className += " select-item_on";
}
}
}
// 补全自己额外新增的没有的选项的选中状态: 武器外观
if ("arms_clothes_series" in paramObj) {
const armsList = document.querySelectorAll("#arms_clothes_series > li.select-item");
for (const item of armsList) {
const xrName = item.getAttribute("data-val");
if (paramObj["arms_clothes_series"].indexOf(xrName) !== -1 && item.className.indexOf("select-item_on") === -1) {
item.className += " select-item_on";
}
}
}
// 添加一个赛季服搜索页面用于搜索环身的按钮
const submitBox = document.querySelector("body > div.l_Con > section.filter > div > div > div > div.submit-con.l_Clearfix");
let queryHuanshen = document.createElement("a");
queryHuanshen.href = "javascript:void(0);"
queryHuanshen.className = "btn-sarch btn-red";
queryHuanshen.innerHTML = "+环身搜索";
queryHuanshen.style.zIndex = "9999";
// 创建一个筛选环身的悬浮框
const popup = document.createElement("div");
popup.style.position = "fixed";
popup.style.top = "10px";
popup.style.right = "120px"; // 放在按钮的右侧
popup.style.width = "200px";
popup.style.padding = "10px";
popup.style.backgroundColor = "white";
popup.style.border = "1px solid #ccc";
popup.style.boxShadow = "0 0 10px rgba(0,0,0,0.5)";
popup.style.zIndex = "9999";
popup.style.display = "none"; // 初始隐藏
// 用于创建选项元素的函数
const createOption = (id, labelText) => {
const option = document.createElement("input");
option.type = "checkbox";
option.id = id;
const label = document.createElement("label");
label.style = "display:inline-block;line-height:30px;background-color:#eeeeee;color:black;padding-left:10px;padding-right:10px;border-radius:5px;margin:10px;";
label.htmlFor = id;
label.innerText = labelText;
const container = document.createElement("div");
container.appendChild(option);
container.appendChild(label);
return container;
};
// 添加环身选项
popup.appendChild(createOption("炽火祥麟", "炽火祥麟"));
popup.appendChild(createOption("蛰雷咤夜", "蛰雷咤夜"));
// 创建一个提交外加环身搜索的按钮
const submitButton = document.createElement("a");
submitButton.href = "javascript:void(0);";
submitButton.className = "btn-sarch btn-red";
submitButton.innerHTML = "搜索";
submitButton.addEventListener("click", () => {
const selectedOptions = [];
if (document.getElementById("炽火祥麟").checked) selectedOptions.push("炽火祥麟");
if (document.getElementById("蛰雷咤夜").checked) selectedOptions.push("蛰雷咤夜");
const finalSelect = selectedOptions.join(",");
console.log(`Selected options: ${finalSelect}`);
popup.style.display = "none"; // 隐藏悬浮框
if (finalSelect.length > 0) {
paramObj["huanshen_name"] = finalSelect;
paramObj["huanshen_name_match_all"] = "or";
paramObj["order"] = "price+ASC";
let newURL = `${rootURL}?${Object.entries(paramObj).map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v).replace(/%2B/g, '+')}`).join("&")}`;
window.location.href = newURL;
}
});
popup.appendChild(submitButton);
// 将悬浮框添加到页面
document.body.appendChild(popup);
// 添加按钮点击事件,显示或隐藏悬浮框
queryHuanshen.addEventListener("click", () => {
if (popup.style.display === "none") {
const rect = queryHuanshen.getBoundingClientRect();
popup.style.top = `${rect.top}px`;
popup.style.left = `${rect.right + 10}px`;
popup.style.display = "block";
} else {
popup.style.display = "none";
}
});
submitBox.appendChild(queryHuanshen);
} else {
console.log("逆水寒藏宝阁商品补全油猴脚本:Required parameters are not present.");
}
})();