Greasy Fork 还支持 简体中文。

Kbin CSS Fix

Fixes broken magazine CSS on /kbin.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Kbin CSS Fix
// @namespace    pamasich-kbin
// @version      1.0
// @description  Fixes broken magazine CSS on /kbin.
// @author       Pamasich
// @match        https://kbin.social/*
// @match        https://kbin.earth/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=kbin.social
// @license      MIT
// @grant        none
// ==/UserScript==
 
/*
    /kbin currently breaks any magazine CSS that uses the characters '>' or '&', by replacing
    them with their HTML escape codes. This userscript is meant to revert that and make the
    CSS work again.
*/

function setup () {
    var dummy = document.createElement("div");
    document.querySelectorAll("style:not([id])").forEach((style) => {
        dummy.innerHTML = style.textContent;
        if (dummy.innerHTML != dummy.textContent) {
            style.textContent = dummy.textContent;
        }
    });
    dummy.remove();
}

setup();

const observer = new MutationObserver((mutations) => {
    // ensure the observer only triggers if the user navigated via turbo mode
    if (mutations.some((mutation) => Array.from(mutation.addedNodes).some((node) => node.nodeName == "BODY"))) setup();
});
// observing the entire document because of turbo mode
observer.observe(document, { childList: true, subtree: true });