ISO Userscript

Talk about Forum Mafia feedback, suggestions, etc here.

Moderators: Varanus, FM Game Moderators

Re: ISO Userscript

Postby iggyvolz » Sun Jan 28, 2018 1:03 am

Exacerbated wrote:Does this not work for firefox anymore? Can't get it to work.

I actually just tried this the other day and it didn't work. Copying the javascript into the console makes it work though, so I'm guessing it's an issue either with Greasemonkey or with how it's loaded.
Greatest failures/shitshows:
User avatar
iggyvolz
Werewolf
Werewolf
 
Posts: 3258
Joined: Wed Mar 26, 2014 12:21 pm
Location: /dev/null

Re: ISO Userscript

Postby Schultz128 » Sun Jan 28, 2018 1:09 am

parsec - Today at 1:49 AM
@nerdsnerdsnerds the recent firefox quantum update changed something about extensions, so greasemonkey had to be updated, and now some things are broken when you try to use jquery in a userscript for some reason. if you use tampermonkey instead of greasemonkey it works
User avatar
Schultz128
FM Awards: Creator
FM Awards: Creator
 
Posts: 391
Joined: Fri Apr 10, 2015 10:09 am

Re: ISO Userscript

Postby Duffman3005 » Sun Feb 11, 2018 9:30 am

I couldn't get it to work with Firefox using grease monkey or tamper monkey (followed the steps for manually adding in tamper monkey).
Image
My Forum Mafia Record
Spoiler: Image
User avatar
Duffman3005
Donor
Donor
 
Posts: 172
Joined: Tue May 20, 2014 10:06 pm
Location: Super secret (UTC−06)

Re: ISO Userscript

Postby melanora » Mon Feb 12, 2018 11:14 am

Duffman3005 wrote:I couldn't get it to work with Firefox using grease monkey or tamper monkey (followed the steps for manually adding in tamper monkey).


So I'm actually not even using it on my new computer as tampermonkey was being a douchebag for me, but I'll do it later today if I can find an older tamper version that won't auto-update. If I see anything not working with the script, I'll fix it and post an update. If it works for me, I'll poke you and see if we can work through your issue together?
#overthrowthepatriarchy #babyforfmmod
I'm not a fucking gmod. Don't send me shit about your ban appeal.

Image

FM Record
Spoiler: Image
User avatar
melanora
Retributionist
Retributionist
 
Posts: 371
Joined: Fri Apr 24, 2015 3:44 pm
Location: EST

Re: ISO Userscript

Postby melanora » Mon Feb 12, 2018 11:21 am

Okay so the original script, the one that I posted, and the one that Gent posted all didn't work. Reason being, the host site apparently isn't working? That stated, the one that Iggy posted works, but here's the thing - you need to delete the OLD FM userscript, because otherwise it won't work. To do that, click the tampermonkey button, click create new script, select installed userscripts, then click the trash can.


iggyvolz wrote:http://iggyvolz.github.io/TOS-iso-script/fm-iso.user.js


Go to that link, and then click install. It should work. I'll give it a few more people confirming this works before I update the thread entirely with this link.

Unfortunately, this script was made by someone not around anymore, although someone that is sometimes oddly around has this updated version. I wish I knew more other than fiddling with the small stuff and googling, because then I would host it myself, but I know just enough to make it bearable, and to not have it say MafiaScum at the top. So yeah.
#overthrowthepatriarchy #babyforfmmod
I'm not a fucking gmod. Don't send me shit about your ban appeal.

Image

FM Record
Spoiler: Image
User avatar
melanora
Retributionist
Retributionist
 
Posts: 371
Joined: Fri Apr 24, 2015 3:44 pm
Location: EST

Re: ISO Userscript

Postby Duffman3005 » Mon Feb 12, 2018 5:27 pm

Thank you so much! Just tested and it works beautifully well!! This should prove very useful in the future :D
Image
My Forum Mafia Record
Spoiler: Image
User avatar
Duffman3005
Donor
Donor
 
Posts: 172
Joined: Tue May 20, 2014 10:06 pm
Location: Super secret (UTC−06)

Re: ISO Userscript

Postby EvanManManMan » Thu Feb 15, 2018 2:32 pm

Kirize12 wrote:HOLY SHIT DUFFMAN’S BACK

Woah

You are late
User avatar
EvanManManMan
FM Awards: Town
FM Awards: Town
 
Posts: 233
Joined: Wed Oct 18, 2017 5:40 pm

Re: ISO Userscript

Postby Shilster » Fri Feb 16, 2018 12:59 am

EvanManManMan wrote:
Kirize12 wrote:HOLY SHIT DUFFMAN’S BACK

Woah

You are late

by 20 days
User avatar
Shilster
Werewolf
Werewolf
 
Posts: 3484
Joined: Mon Apr 03, 2017 9:59 pm
Location: (GMT+7)

Re: ISO Userscript

Postby Duffman3005 » Sun Feb 18, 2018 3:54 am

Kirize12 wrote:HOLY SHIT DUFFMAN’S BACK


Whoa just saw this, thanks, nice to see you too :D
Image
My Forum Mafia Record
Spoiler: Image
User avatar
Duffman3005
Donor
Donor
 
Posts: 172
Joined: Tue May 20, 2014 10:06 pm
Location: Super secret (UTC−06)

Re: ISO Userscript

Postby chitownmvp01 » Tue Mar 06, 2018 9:22 pm

Apparently the Chrome one in the OP works on Firefox, but the one listed in the OP for Firefox doesn't work.
Spoiler: Image


Thanks Achro!: Spoiler:
Chitsticks INC.


Favorite Roles: Mayor, Jailor, Investigator, Lookout, Sheriff, Godfather, Consigliere
Least Favorite Roles: Transporter, Jester, Survivor, Disguiser, Mafioso (original, not promoted)
User avatar
chitownmvp01
[Forum Mafia XI] Winner
[Forum Mafia XI] Winner
 
Posts: 8464
Joined: Thu May 01, 2014 4:50 am
Location: Chicagoland (CST/UTC-6 or CDT/UTC-5)

Re: ISO Userscript

Postby melanora » Wed Mar 07, 2018 4:01 pm

chitownmvp01 wrote:Apparently the Chrome one in the OP works on Firefox, but the one listed in the OP for Firefox doesn't work.


I don't use FF at all so I doubt that the one listed for FF has even been updated at all.
#overthrowthepatriarchy #babyforfmmod
I'm not a fucking gmod. Don't send me shit about your ban appeal.

Image

FM Record
Spoiler: Image
User avatar
melanora
Retributionist
Retributionist
 
Posts: 371
Joined: Fri Apr 24, 2015 3:44 pm
Location: EST

Re: ISO Userscript

Postby destawaits » Thu Apr 05, 2018 3:37 am

Tampermonkey is available for Safari, too, so you can use FM Numberer on Safari.

Spoiler:
User avatar
destawaits
Serial Killer
Serial Killer
 
Posts: 2439
Joined: Sat Sep 19, 2015 1:14 am
Location: Discord [UTC-8]

Re: ISO Userscript

Postby Varanus » Sat Jun 09, 2018 1:26 pm

Code: Select all
// ==UserScript==
// @name        FM Post Numberer
// @namespace   http://blankmediagames.com
// @author      deferentsheep
// @description Numbers posts and adds ISO
// @include     http://blankmediagames.com/phpbb/*
// @include     http://www.blankmediagames.com/phpbb/*
// @include     https://blankmediagames.com/phpbb/*
// @include     https://www.blankmediagames.com/phpbb/*
// @grantnone
// @version     1.0.8
// ==/UserScript==
// --------------------
// Configurable parameters, you may change values here
// If true, runs the script in every subforum, otherwise only in those specified by desiredForums.
var allForums = true;

// List of forums to run the script on if allForums is false. Works with subforums as well (e.g. "Forum Mafia" will enable the script in "Signups", "Game Threads", etc.).
var desiredForums = ["Game Threads", "FM Discussion"];

// --------------------

function actualThing() {

    var willRun = false;
    $(".icon-home > a").each(function(index, value) {
        var label = $(this).html();
        var i;
        for (i = 0; !willRun && i < desiredForums.length; i++) {
            if (label == desiredForums[i]) {
                willRun = true;
            }
        }
    });

    if (!allForums && !willRun) {
        return;
    }

    var fullURL = window.location.href;
    var threadURL = $("h2").first().children("a").first().attr("href");
    var threadNumber = "";
    var startNumber = "";
    if(fullURL.indexOf("start=") !== -1)
    {
        var j = fullURL.search("start=") + 6;
        while(!isNaN(fullURL[j]))  {
            startNumber += fullURL[j++];
        }
    }
    var i = threadURL.search("&t=") + 3;
    while (!isNaN(threadURL[i])) {
        threadNumber += threadURL[i++];
    }

    var pageNumber = $(".pagination").find("strong").first().html();

    $(".post").each(function(index, value) {
        if ($(this).children(".inner").first().children(".postprofile").length !== 0) {
            var postID = $(this).attr("id").substring(1);
            var postNumber = startNumber == "" ? (pageNumber - 1) * 25 + index : Number(startNumber) + index;
            var authorLine = $(this).find(".author");
            var authorName = authorLine.find("strong").first().children("a").html();
            var authorString = authorLine.html();

            var insertIndex = authorString.search("</a>by") + 4;
            authorString = "Post <a href=\"./viewtopic.php?p=" + postID + "#p" + postID + "\"><strong>#" + postNumber + "</strong></a> " + authorString.substring(insertIndex, authorString.length);
            insertIndex = authorString.search("» ");
            authorString = authorString.substring(0, insertIndex) + " (<a href=\"./search.php?t=" + threadNumber + "&author=" + authorName + "\">ISO</a>)" + authorString.substring(insertIndex, authorString.length);
            authorLine.html(authorString);
        }
        if ($(this).children(".inner").first().children(".postbody").first().children(".content").length !== 0) {
            var contentLine = $(this).children(".inner").first().children(".postbody").first().children(".content").first();
            var contentString = contentLine.html();
            if(contentString.includes("<script>"))
                return;
            var checkNum = 0;
            while(contentString.indexOf("p#", checkNum) !== -1)
            {
                var postNum = "";
                var startVal = contentString.indexOf("p#", checkNum);
                var endVal = startVal + 2;
                checkNum = endVal;
                var isNum = false;
                while(!isNaN(contentString[endVal]))
                {
                    postNum += contentString[endVal++];
                }
                if(postNum !== "")  {
                    contentString = contentString.substring(0, startVal) + "<a href=\"./viewtopic.php?t=" + threadNumber + "&start=" + postNum + "\">#" + postNum + "</a>" + contentString.substring(endVal, contentString.length);
                }
            }
            contentLine.html(contentString);
        }
    });
}

function loadScript(src, callback) {
    var s, r, t;
    r = false;
    s = document.createElement("script");
    s.type = "text/javascript";
    s.src = src;
    s.onload = s.onreadystatechange = function() {
        if (!r && (!this.readyState || this.readyState == "complete")) {
            r = true;
            callback();
        }
    };
    t = document.getElementsByTagName("script")[0];
    t.parentNode.insertBefore(s, t);
}

loadScript("//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js", actualThing);


Updated stuff based on things in the Q&A thread
Only tested it out with stuff on Chrome, so let me know if it doesn't work somewhere else

Notes:
All threads start at post 0 instead of post 1
Now shows correct post number when the first post displayed on the page is not an even 25th
Replaces "p#{number}" in posts with a link to that post in the current thread
Last edited by Varanus on Sat Jun 09, 2018 2:33 pm, edited 2 times in total.
You were expecting a decent signature...

BUT IT WAS ME! DIO!
User avatar
Varanus
FM Lead Moderator
FM Lead Moderator
 
Posts: 698
Joined: Fri Mar 06, 2015 10:08 am
Location: Lurking

Re: ISO Userscript

Postby chitownmvp01 » Sat Jun 09, 2018 1:54 pm

Varanus wrote:
Code: Select all
// ==UserScript==
// @name        FM Post Numberer
// @namespace   http://blankmediagames.com
// @author      deferentsheep
// @description Numbers posts and adds ISO
// @include     http://blankmediagames.com/phpbb/*
// @include     http://www.blankmediagames.com/phpbb/*
// @include     https://blankmediagames.com/phpbb/*
// @include     https://www.blankmediagames.com/phpbb/*
// @grantnone
// @version     1.0.8
// ==/UserScript==
// --------------------
// Configurable parameters, you may change values here
// If true, runs the script in every subforum, otherwise only in those specified by desiredForums.
var allForums = true;

// List of forums to run the script on if allForums is false. Works with subforums as well (e.g. "Forum Mafia" will enable the script in "Signups", "Game Threads", etc.).
var desiredForums = ["Game Threads", "FM Discussion"];

// --------------------

function actualThing() {

    var willRun = false;
    $(".icon-home > a").each(function(index, value) {
        var label = $(this).html();
        var i;
        for (i = 0; !willRun && i < desiredForums.length; i++) {
            if (label == desiredForums[i]) {
                willRun = true;
            }
        }
    });

    if (!allForums && !willRun) {
        return;
    }

    var fullURL = window.location.href;
    var threadURL = $("h2").first().children("a").first().attr("href");
    var threadNumber = "";
    var startNumber = "";
    if(fullURL.indexOf("start=") !== -1)
    {
        var j = fullURL.search("start=") + 6;
        while(!isNaN(fullURL[j]))  {
            startNumber += fullURL[j++];
        }
    }
    var i = threadURL.search("&t=") + 3;
    while (!isNaN(threadURL[i])) {
        threadNumber += threadURL[i++];
    }

    var pageNumber = $(".pagination").find("strong").first().html();

    $(".post").each(function(index, value) {
        if ($(this).children(".inner").first().children(".postprofile").length !== 0) {
            var postID = $(this).attr("id").substring(1);
            var postNumber = startNumber == "" ? (pageNumber - 1) * 25 + index : Number(startNumber) + index;
            var authorLine = $(this).find(".author");
            var authorName = authorLine.find("strong").first().children("a").html();
            var authorString = authorLine.html();

            var insertIndex = authorString.search("</a>by") + 4;
            authorString = "Post <a href=\"./viewtopic.php?p=" + postID + "#p" + postID + "\"><strong>#" + postNumber + "</strong></a> " + authorString.substring(insertIndex, authorString.length);
            insertIndex = authorString.search("» ");
            authorString = authorString.substring(0, insertIndex) + " (<a href=\"./search.php?t=" + threadNumber + "&author=" + authorName + "\">ISO</a>)" + authorString.substring(insertIndex, authorString.length);
            authorLine.html(authorString);
        }
        if ($(this).children(".inner").first().children(".postbody").first().children(".content").length !== 0) {
            var contentLine = $(this).children(".inner").first().children(".postbody").first().children(".content").first();
            var contentString = contentLine.html();
            var checkNum = 0;
            while(contentString.indexOf("p#", checkNum) !== -1)
            {
                var postNum = "";
                var startVal = contentString.indexOf("p#", checkNum);
                var endVal = startVal + 2;
                checkNum = endVal;
                var isNum = false;
                while(!isNaN(contentString[endVal]))
                {
                    postNum += contentString[endVal++];
                }
                if(postNum !== "")  {
                    contentString = contentString.substring(0, startVal) + "<a href=\"./viewtopic.php?t=" + threadNumber + "&start=" + postNum + "\">#" + postNum + "</a>" + contentString.substring(endVal, contentString.length);
                }
            }
            contentLine.html(contentString);
        }
    });
}

function loadScript(src, callback) {
    var s, r, t;
    r = false;
    s = document.createElement("script");
    s.type = "text/javascript";
    s.src = src;
    s.onload = s.onreadystatechange = function() {
        if (!r && (!this.readyState || this.readyState == "complete")) {
            r = true;
            callback();
        }
    };
    t = document.getElementsByTagName("script")[0];
    t.parentNode.insertBefore(s, t);
}

loadScript("//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js", actualThing);


Updated stuff based on things in the Q&A thread
Only tested it out with stuff on Chrome, so let me know if it doesn't work somewhere else

Notes:
All threads start at post 0 instead of post 1
Now shows correct post number when the first post displayed on the page is not an even 25th
Replaces "p#{number}" in posts with a link to that post in the current thread


It works, however, it messes up the page numbers. For example, I tried linking post#90 in 15C and it became the first post of page 4, which isn't possible since 25 posts are displayed per page.

Also, on all of the other unlocked completed games threads, this happened. It did not occur on any other game threads (locked completed and ongoing) ones that I tried clicking on. Does this have any relation to your userscript? The same issue did not occur once I turned off your userscript and turned the old one back on.
Spoiler: Image


Thanks Achro!: Spoiler:
Chitsticks INC.


Favorite Roles: Mayor, Jailor, Investigator, Lookout, Sheriff, Godfather, Consigliere
Least Favorite Roles: Transporter, Jester, Survivor, Disguiser, Mafioso (original, not promoted)
User avatar
chitownmvp01
[Forum Mafia XI] Winner
[Forum Mafia XI] Winner
 
Posts: 8464
Joined: Thu May 01, 2014 4:50 am
Location: Chicagoland (CST/UTC-6 or CDT/UTC-5)

Re: ISO Userscript

Postby Varanus » Sat Jun 09, 2018 2:06 pm

chitownmvp01 wrote:It works, however, it messes up the page numbers. For example, I tried linking post#90 in 15C and it became the first post of page 4, which isn't possible since 25 posts are displayed per page.

Also, on all of the other unlocked completed games threads, this happened. It did not occur on any other game threads (locked completed and ongoing) ones that I tried clicking on. Does this have any relation to your userscript? The same issue did not occur once I turned off your userscript and turned the old one back on.

It works by using "start={postNum}" in the URL
Under normal circumstances (going to a post by ID, or just hitting a page #), that will always be a multiple of 25
It just lists you as being on whatever page that post would normally be on at the page numbers

I have no idea what's causing that in the screenshot. There shouldn't be anything in the script that edits anything but specifically the lines we want to edit, which would now be the author and post content lines.

EDIT: Vote/Time tags are screwing this up, probably because I'm editing the line where there is apparently embedded scripts inside the posts. Give me a bit here.
You were expecting a decent signature...

BUT IT WAS ME! DIO!
User avatar
Varanus
FM Lead Moderator
FM Lead Moderator
 
Posts: 698
Joined: Fri Mar 06, 2015 10:08 am
Location: Lurking

Re: ISO Userscript

Postby Varanus » Sat Jun 09, 2018 2:21 pm

Updated the userscript to just ignore the posts with script tags in them
I'm not going to deal with finding a proper solution to this mess
Just don't try to link posts in the same post you use time/vote tags
You were expecting a decent signature...

BUT IT WAS ME! DIO!
User avatar
Varanus
FM Lead Moderator
FM Lead Moderator
 
Posts: 698
Joined: Fri Mar 06, 2015 10:08 am
Location: Lurking

Re: ISO Userscript

Postby chitownmvp01 » Sat Jun 09, 2018 6:18 pm

Varanus wrote:Updated the userscript to just ignore the posts with script tags in them
I'm not going to deal with finding a proper solution to this mess
Just don't try to link posts in the same post you use time/vote tags


Linking posts in a post that also includes time/vote tags isn't what's causing the issue in the screenshot I posted. It occurs when clicking on the thread.
Spoiler: Image


Thanks Achro!: Spoiler:
Chitsticks INC.


Favorite Roles: Mayor, Jailor, Investigator, Lookout, Sheriff, Godfather, Consigliere
Least Favorite Roles: Transporter, Jester, Survivor, Disguiser, Mafioso (original, not promoted)
User avatar
chitownmvp01
[Forum Mafia XI] Winner
[Forum Mafia XI] Winner
 
Posts: 8464
Joined: Thu May 01, 2014 4:50 am
Location: Chicagoland (CST/UTC-6 or CDT/UTC-5)

Re: ISO Userscript

Postby Varanus » Sun Jun 10, 2018 9:56 am

chitownmvp01 wrote:
Varanus wrote:Updated the userscript to just ignore the posts with script tags in them
I'm not going to deal with finding a proper solution to this mess
Just don't try to link posts in the same post you use time/vote tags


Linking posts in a post that also includes time/vote tags isn't what's causing the issue in the screenshot I posted. It occurs when clicking on the thread.

I'm saying not to link posts in the same posts as vote counts/time tags because the script now skips over those posts, as those are the source of the issue.
You were expecting a decent signature...

BUT IT WAS ME! DIO!
User avatar
Varanus
FM Lead Moderator
FM Lead Moderator
 
Posts: 698
Joined: Fri Mar 06, 2015 10:08 am
Location: Lurking

Previous

Return to FM Discussion

Who is online

Users browsing this forum: No registered users and 7 guests