Handy Greasemonkey scripts for forum use

Users who are viewing this thread

It's on the top-right corner.
REpO1.jpg
 
Ohhh. Never had even acknowledged it was there. :razz:

Dusk Voyager said:
Don't think so, because it can't retrieve the post ID from a post on the printable version as far as I understand.
Nope, but you can add IDs to the posts!

That said, Open All Spoilers now supports print mode pages. If not, please report back.
Also adds button to open/close all spoilers on the page in both modes.

Open All Spoilers v. 2015.07.20.b
Download/install
Source
 
Updated all of my scripts, 'cause I hadn't taken into account that the forum might start to use the https protocol. If you find the ones you're using don't work, just grab new versions from the OP (links'll be the same as with the old ones), or just edit them and change the
Code:
// @include     http://forums.taleworlds.com/...
lines to
Code:
// @include     *://forums.taleworlds.com/...

Could also change 'em to https:// but decided to keep it at that, in case somehow you manage to load a http:// version of a page at some point.
Considered "http*://" too, but apparently chrome throws a hissyfit over that, according to an article I spotted.
 
J said:
Could also change 'em to https:// but decided to keep it at that, in case somehow you manage to load a http:// version of a page at some point.
For now, existing HTTP links to the forum will load the page as HTTP rather than just redirect to HTTPS. All forum links within the page however will point to HTTPS, other than within user posts and signatures and such.
At some point I'll probably run a couple of database queries to update forum links within posts, signatures, and PMs so that they're HTTPS instead of HTTP.
 
Seeing as you can already find out which old name used to belong to whom by just entering the old name on the member search page, why not do it the other way around?

This Tampermonkey script (more of a Chrome person) creates a new text box on the member search page where you can enter a certain user's current name to retrieve the URL of the oldest Wayback Machine version of the user profile page right below the text box, allowing you to see the former names of users.

Code:
// ==UserScript==
// @name         exname
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  how we got here
// @author       You
// @include      https://forums.taleworlds.com/index.php?action=mlist;sa=search
// @include      http://forums.taleworlds.com/index.php?action=mlist;sa=search
// @grant        none
// ==/UserScript==

ns = document.body.getElementsByClassName("navigate_section")[0];
exInp = document.createElement("input");

exBtn = document.createElement("button");
ns.appendChild(exInp);
ns.appendChild(exBtn);
exBtn.innerText= "Get former name";
ssURL = document.head.getElementsByTagName("link")[0].href.match(/\w{1,}/g);
srcTxtr = "url('" + ssURL[0] + "://" + ssURL[1] + "." + ssURL[2] + "." + ssURL[3] + "/" + ssURL[4] + "/" + ssURL[5] + "/" + "images/button_a.jpg" + "')";
lnk = document.createElement("a");
lnk.href = "#";
lnk.innerText="#";
ns.appendChild(lnk);
lnk.style.display = "none";

exBtn.style.backgroundImage = srcTxtr;
exBtn.addEventListener("click",function(){
curUsername = exInp.value;
var xhttp = new XMLHttpRequest();
  xhttp.open("POST", "https://forums.taleworlds.com/index.php?action=mlist;sa=search;search="+curUsername+";submit=Search;fields=name", true);

  xhttp.onreadystatechange = function() {
      
    if (this.readyState == 4 && this.status == 200) {
          rt = this.responseText;
        x = rt.match(/a href[ ]{0,}[=]{1,}[ "]{1,}\S{1,}[ "]{1,}[t]{1}[i]{1}[t]{1}[l]{1}[e]{1}[ ]{0,}[=]{1,}[ "]{1,}[V]{1}[i]{1}[e]{1}[w]{1}/g);
        num = x[0].match(/\d{1,}/g)[0];
        
        userURL = "https://forums.taleworlds.com/index.php?action=profile;u=" + num;
        wmURL = "https://web.archive.org/web/0/" + userURL;

        lnk.style.display = "block";
        lnk.style.padding = "5px";
        lnk.href = wmURL;
        lnk.innerText = "Click!";
        lnk.target = "_blank";
    }
  };
  xhttp.send();
});
Just note that it may or may not work depending on whether an old page with a former name is stored on Wayback Machine at all.



PS. This one works on any profile page:
Code:
ns = document.body.getElementsByClassName("navigate_section")[0];

exBtn = document.createElement("button");
ns.appendChild(exBtn);
exBtn.innerText= "Get former name";
ssURL = document.head.getElementsByTagName("link")[0].href.match(/\w{1,}/g);
srcTxtr = "url('" + ssURL[0] + "://" + ssURL[1] + "." + ssURL[2] + "." + ssURL[3] + "/" + ssURL[4] + "/" + ssURL[5] + "/" + "images/button_a.jpg" + "')";
lnk = document.createElement("a");
lnk.href = "#";
lnk.innerText="#";
ns.appendChild(lnk);
lnk.style.display = "none";

exBtn.style.backgroundImage = srcTxtr;
exBtn.addEventListener("click",function(){
        
        userURL = window.location.href;
        wmURL = "https://web.archive.org/web/0/" + userURL;

        lnk.style.display = "block";
        lnk.style.padding = "5px";
        lnk.href = wmURL;
        lnk.innerText = "Click!";
        lnk.target = "_blank";
    });


PPS. This one creates small buttons on the dev blog board showing the relevant blog's entry order and intended title (not "Dev Blog dd/mm/yy"):

Code:
// ==UserScript==
// @name         blogs
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @include        https://forums.taleworlds.com/index.php/board,253*
// @include        https://www.taleworlds.com/en/Shared/AllNewsPartial?section=6&pageIndex=1&pageSize=1000*
// @include        https://forums.taleworlds.com/index.php?*
// @grant        none
// ==/UserScript==


 var curWindow = window.location.href;
 var segs = "x.y";
let threadLinkStrings = [];
let usableThreadLinks = [];
let entryTitlesDesc = [];
let entryTitlesAsc = [];

 if(curWindow !== null && curWindow !== undefined && curWindow !== ""){
 var segs = curWindow.match(/\w{1,}/g);
 }
     
if (window.innerWidth > 2  && window.innerHeight > 2) {

let threadLinks = document.getElementsByTagName("a");


for(let j=0;j<threadLinks.length;j++){
    if(threadLinks[j].innerText.match(/Dev Blog/g) && threadLinks[j].href.match(/topic/g) && threadLinks[j].href.match(/[.]{1}0[.]{1}/g) && !threadLinks[j].href.match(/msg/g)){
        usableThreadLinks[usableThreadLinks.length] = threadLinks[j];
        let parentEl = threadLinks[j].parentElement;
        
        let smallBtn = document.createElement("button");
        smallBtn.innerText = "More";
        smallBtn.style.background = "url('https://forums.taleworlds.com/Themes/TWcurve/images/theme/menu_gfx.png')";
        smallBtn.addEventListener("click", function(event){
            event.preventDefault();
        });
        
        smallBtn.addEventListener("click", function(event){
                  
            let parent = event.target.parentElement;
            let aElement = parent.getElementsByTagName("a")[0];
                        
            var xhttp = new XMLHttpRequest();
            xhttp.open("GET", aElement.href, true);
            xhttp.send();
            
            setTimeout(function(){
                if(!aElement.innerText.match(/ - Blog /g)){
                    let firstPage = xhttp.responseText;
                    let blogPic = firstPage.match(/blog_post/g)[0];
                    let entryNo = parseInt(firstPage.match(/blog_post_\d{1,}_taleworldswebsite/g)[0].match(/\d{1,}/g)[0])+16;
                    
                    let miniFrame = document.createElement("iframe"); // because sending requests didn't work
                    miniFrame.id = "mini";
                    miniFrame.width=2;
                    miniFrame.height=2;
                    miniFrame.src = "https://forums.taleworlds.com/index.php?no="+entryNo;
                    document.body.appendChild(miniFrame);
            
                    let txt = aElement.innerText;
                    aElement.innerText = txt + " - Blog " + entryNo;
                    
                    setTimeout(function(){
                        let mf = document.getElementById("mini");
                        txt = aElement.innerText;
                        
                        let cleanTitle = decodeURI(mf.src.substring(40));
                        aElement.innerText = txt + ": " + cleanTitle;
                        mf.remove();
                    },6000);
                    }
             },600); // give enough time for the site to load
            
            
        });
        
        parentEl.appendChild(smallBtn);
    }    
  }
}

else if (segs[1] == "forums" && location.href.match(/[?]{1}no[=]{1}/g)){
    location.assign("https://www.taleworlds.com/en/Shared/AllNewsPartial?section=6&pageIndex=1&pageSize=1000&"+ segs[7] );

    setTimeout(function(){
    },10000);
}
else if(segs[1]=="www"){    
    let lnks=document.getElementsByTagName("a");
    
    for(let i=0;i<lnks.length;i++){
        let lnkTitle = lnks[i].innerText;
                        
        if(lnkTitle != "Mount & Blade II: Bannerlord at E3 2017 – Reactions"
        && lnkTitle != "Mount & Blade II: Bannerlord - Battles and Combat Detailed at E3"
        && lnkTitle != "Mount & Blade II: Bannerlord at E3 2017 – Where to Watch"
        && lnkTitle != "Mount & Blade II: Bannerlord Playable At E3 2017"
        && lnkTitle != "Mount & Blade II: Bannerlord Featured on PC Gamer Magazine Cover!"
        && lnkTitle != "Mount & Blade II: Bannerlord on Steam"
        && lnkTitle != "Mount & Blade II: Bannerlord @ Gamescom 2016"
        && lnkTitle != "Bannerlord Sieges Revealed at E3"
        && lnkTitle != "Mount & Blade II: Bannerlord at E3 2016"
        && lnkTitle != "Rock, Paper, Shotgun Interview!"
        && lnkTitle != "40 minutes of gameplay at PC Gamer Weekender"
        && lnkTitle != "Mount & Blade II: Bannerlord – First glimpse"
        && lnkTitle != "Mount & Blade II: Bannerlord at E3 2016"
        && lnkTitle != "Mount&Blade II: Bannerlord Announcement!"){
           entryTitlesDesc[entryTitlesDesc.length] = lnkTitle;
           }
    }
        entryTitlesAsc = entryTitlesDesc.reverse();
        location.replace("https://forums.taleworlds.com/index.php?" + entryTitlesAsc[segs[13]-1]);
}

else if (segs[1] == "forums" && !location.href.match(/[?]{1}no[=]{1}/g)){
    let frm = window.frameElement;
    if(frm.src != location.href){
    frm.src = location.href;
    }
}
 
Back
Top Bottom