lecFix

Fix [l=c] link created by RES.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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();