Greasy Fork is available in English.
Minimalistic enhancements for 52pojie.
当前为
// ==UserScript==
// @name 52 Enhance
// @namespace http://tampermonkey.net/
// @version 0.1.4
// @description Minimalistic enhancements for 52pojie.
// @author PRO
// @match https://www.52pojie.cn/*
// @icon http://52pojie.cn/favicon.ico
// @grant none
// @license gpl-3.0
// ==/UserScript==
(function() {
'use strict';
// Dynamic opacity
let config = {
opacity: {
"default": 0.2,
"hover": 0.8,
"none": 0.8,
"transition": "opacity 0.2s ease-in-out"
}
};
let css = document.createElement("style");
css.textContent = `
#jz52top {
opacity: ${config.opacity.default};
transition: ${config.opacity.transition};
}
#jz52top:hover {
opacity: ${config.opacity.hover};
}
@media (any-hover: none) {
#jz52top {
opacity: ${config.opacity.none};
}
#jz52top:hover {
opacity: ${config.opacity.none};
}
}
.authicn {
cursor: initial;
}
`;
document.head.appendChild(css);
// Hide code
function toggleCode() {
let code = this.parentNode.parentNode.lastChild;
if (code.style.display == "none") {
code.style.display = "";
this.textContent = " 隐藏代码";
} else {
code.style.display = "none";
this.textContent = " 显示代码";
}
}
document.querySelectorAll("em.viewsource").forEach(ele => {
let hide_code = document.createElement("em");
hide_code.setAttribute("style", ele.getAttribute("style"));
hide_code.setAttribute("num", ele.getAttribute("num"));
hide_code.textContent = " 隐藏代码";
hide_code.addEventListener("click", toggleCode);
ele.parentNode.appendChild(hide_code);
});
// Double click navbar to get to top
document.getElementById("nv").addEventListener("dblclick", e => {
window.scrollTo({ top: 0, behavior: "smooth" });
});
// Change get to top button behavior (use vanilla solution)
document.getElementById("goTopBtn").onclick = e => {
window.scrollTo({ top: 0, behavior: "smooth" });
};
// Hide all top threads
let display = Boolean(document.querySelectorAll("tbody[id^='stickthread_']").length);
let table = document.getElementById("threadlisttableid");
if (display && table) {
function hideAll() {
document.querySelectorAll("tbody[id^='stickthread_']").forEach(ele => {
let close = ele.querySelector("a.closeprev");
if (close) close.click();
});
}
let tooltip = document.querySelector("div#threadlist > div.th > table > tbody > tr > th > div.tf");
let show_top = tooltip.querySelector("span#clearstickthread");
show_top.removeAttribute("style");
show_top.insertAdjacentHTML("beforeend", " ");
let hide_all = document.createElement("a");
hide_all.href = "javascript:;";
hide_all.className = "xi2";
hide_all.textContent = "隐藏置顶";
hide_all.title = "隐藏置顶";
hide_all.addEventListener("click", hideAll);
show_top.insertAdjacentElement("beforeend", hide_all);
}
// Hide reply
function toggleReplyHeader() {
let reply = this.parentNode.parentNode.parentNode.nextSibling;
if (reply.style.display == "none") {
reply.style.display = "";
} else {
reply.style.display = "none";
}
}
let headers = document.querySelectorAll("div.pti > div.authi");
headers.forEach(header => {
let pipe = document.createElement("span");
pipe.classList.add("pipe");
pipe.textContent = "|";
let toggle = document.createElement("a");
toggle.href = "javascript:void(0);";
toggle.textContent = "隐藏/显示";
toggle.addEventListener("click", toggleReplyHeader);
if (header.querySelector("span.none")) {
pipe.classList.add("show");
toggle.classList.add("show");
}
header.insertAdjacentElement("beforeend", pipe);
header.insertAdjacentElement("beforeend", toggle);
});
function toggleReplyFooter() {
let reply = this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.firstChild.lastChild.lastElementChild;
if (reply.style.display == "none") {
reply.style.display = "";
} else {
reply.style.display = "none";
}
}
let footers = document.querySelectorAll("td.plc >div.po.hin > div.pob.cl > p");
footers.forEach(footer => {
let toggle = document.createElement("a");
toggle.href = "javascript:void(0);";
toggle.textContent = "隐藏/显示";
toggle.addEventListener("click", toggleReplyFooter);
footer.insertAdjacentElement("beforeend", toggle);
});
})();