You are viewing the MafiaScum.net Wiki. To play the game, visit the forum.

Northsidegal/Scripts/Marathon: Difference between revisions

From MafiaWiki
Jump to navigation Jump to search
(create page)
 
Line 57: Line 57:


==The Script Itself==
==The Script Itself==
If you need a reminder on what exactly to do with this or how to install it, check [[Northsidegal/Scripts|my main scripts page]]. If you have any more questions or things aren't working for some reason, please feel free to PM me.
Unfortunately, due to the MafiaWiki spam filter, you'll have to find the actual code itself [https://forum.mafiascum.net/viewtopic.php?f=90&t=85078 here]. I'm very sorry that this already very complicated process has to have this extra, very silly step. If you need a reminder on what exactly to do with this or how to install it, check [[Northsidegal/Scripts|my main scripts page]]. If you have any more questions or things aren't working for some reason, please feel free to PM me.
 
  // ==UserScript==
  // @name          Mafiascum: Relive Marathon Games
  // @namespace    https://www.mafiascum.net/
  // @author        northsidegal
  // @description  View older marathon games as if in real-time
  // @include      https://forum.mafiascum.net/viewtopic.php?f=156&t=*
  // @version      1.0
  // @icon          http://www.mafiascum.net/favicon.ico
  // @require      TODO
  // @grant        GM_getValue
  // @grant        GM_setValue
  // @grant        GM_registerMenuCommand
  // @grant        GM_addStyle
  // ==/UserScript==
  try {
      var cfg = new MonkeyConfig({
        title: 'Marathon Game Re-liver Configuration',
        menuCommand: true,
        params: {
            original_post_timestamp: {
              type: 'text',
              label: "Original Post's Timestamp",
              default: Date().toString()
            },
            readthrough_start_time: {
              type: 'text',
              label: "Your read-through start time. Click \"Set Defaults\" for current time.",
              default: Date().toString()
            },
            readthrough_current_time: {
              type: 'text',
              label: "Time since your read-through began. Change only if you'd like to skip ahead.",
              default: "default"
            },
            replacement: {
              type: 'select',
              label: "Replace?",
              variant: 'radio column',
              choices: ['Entire Post', 'Text Only'],
              default: 'Entire Post'
            }
        }
      });
      console.log("starting");
      let thread = document.getElementById("page-body");
      let posts = thread.getElementsByClassName("post");
      for(var i=0;i<posts.length;i++) {
        let post = posts[i];
        let postAuthor = post.getElementsByClassName("postbody")[0].getElementsByClassName("author")[0];
        let postTimeStr = postAuthor.childNodes[6].data.slice(27,-4);
        let postTime = new Date(postTimeStr);
        let originalPostTime = new Date(cfg.get("original_post_timestamp"));
        let startingTime = new Date(cfg.get("readthrough_start_time"));
        let now = cfg.get("readthrough_current_time");
        if (now == "default"){
            var currentTime = new Date();
        }else {
            var currentTime = new Date(now);
        }
        console.log(currentTime);
        console.log(startingTime);
        console.log(postTime);
        console.log(originalPostTime);
        if ((currentTime - startingTime) >= (postTime - originalPostTime)){
            // Do nothing.
            // console.log("Doing nothing!");
        } else {
            if (cfg.get("replacement") == "Entire Post"){
              let inner = post.getElementsByClassName("inner")[0];
              inner.innerText = "This post hasn't happened yet!";
            } else {
              let postbody = post.getElementsByClassName("inner")[0].getElementsByClassName("postbody")[0];
              let content = postbody.getElementsByClassName("content")[0];
              content.innerText = "This post hasn't happened yet!";
            }
            console.log("Replacing post!");
        }
      }
  }
  catch(e) {
      console.log("failed");
  }

Revision as of 08:36, 27 November 2020

northsidegal   Played Games   Modded Games   Rulesets   Stats   Setups   Scripts    
Marathon Game Re-liver    


Marathon Game Re-Liver

This is a tool for re-reading marathon games as if you were spectating it as it was happening. As time passes posts will become unhidden as if they were being made in real-time such that after, for example, 5 minutes have passed for you reading the thread, posts made within 5 minutes of the start of the marathon game will be available. (I suppose that it could also work for regular game threads, but I don't expect anyone is really interested in doing that)



How Do I Use It?

I hope that it's not terribly complicated to use, but I do think it's important to understand how it works.

The configuration menu


1. Open the marathon thread that you'd like to re-read.

2. Copy the timestamp of the post that started the game (i.e. the "The game has begun" post or initial votecount from the moderator).

3. Click on your extension menu. You should see "Mafiascum: Re-live Marathon Games" there, and beneath that you should see "Marathon Game Re-liver Configueration". Click on that.

4. Paste the timestamp that you previously copied into the "Original Post's Timestamp" box. If

5. If you're not interested in skipping ahead, you're done! Click "save", and as time passes more posts should appear. You can select whether or not entire posts should be hidden, or only the text content of them.

6. If you'd like to skip ahead a few minutes, copy the read-through start time and advance it however far you want to skip ahead. So if you want to skip ten minutes into the game, replace "default" with the start time plus ten minutes.

An example of replacing text rather than entire posts

Important Points

You'll have a lot smoother experience if your timestamps have seconds enabled. Without them, you'll only see new posts every time the minute rolls over. They're really easy to enable. Go to your user control panel, then go to your board preferences. From there, in global settings (which it'll default to), set your date format to "Custom". It should default to D M d, Y g:i a. You want to set it to D M d, Y g:i:s a. So, all you have to do is add a ":s".

If you run into errors, first try resetting to the defaults. If you've reset, tried putting in your desired values again and things still don't work, check that the timestamps that you're inputting aren't formatted incorrectly in some way.


The Script Itself

Unfortunately, due to the MafiaWiki spam filter, you'll have to find the actual code itself here. I'm very sorry that this already very complicated process has to have this extra, very silly step. If you need a reminder on what exactly to do with this or how to install it, check my main scripts page. If you have any more questions or things aren't working for some reason, please feel free to PM me.