lecFix

Fix [l=c] link created by RES.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         lecFix
// @namespace    lecFix
// @version      0.1.4
// @description  Fix [l=c] link created by RES.
// @author       kusotool
// @include      http://*.reddit.com/*
// @include      https://*.reddit.com/*
// @grant        none
// ==/UserScript==

var lastpage = 0;
var regex = /page-(\d{1,4})/;

function lecFix(){
    var page = findLastPage();
    
    if(lastpage != page){
        var e = document.getElementsByTagName("span");
        for(var i = 0; i < e.length; i++){
            if(e[i].innerHTML === "[l=c]"){
                e[i].setAttribute("thisComments", decodeURI(e[i].getAttribute("thisComments")));
            }
        }
        lastpage = page;
    }    

    setTimeout(lecFix, 1000);
}

function findLastPage(){
    var n = 1;
    var es = document.getElementsByTagName("div");
    for(var i = es.length - 1; i >= 0; i--){
        if(es[i].getAttribute("class") === "NERPageMarker"){
            if(regex.test(es[i].id)){
                n = parseInt(es[i].id.replace(regex, "$1"));
                break;
            }
        }
    }
    return n;
}

lecFix();