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

Northsidegal/Scripts: Difference between revisions

From MafiaWiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 39: Line 39:
   // @name          Mafiascum: Highlight Alignments
   // @name          Mafiascum: Highlight Alignments
   // @namespace    https://www.mafiascum.net/
   // @namespace    https://www.mafiascum.net/
  // @author        northsidegal
   // @description  Highlight a flipped user's posts red or green depending on alignment
   // @description  Highlight a flipped user's posts red or green depending on alignment
   // @include      https://forum.mafiascum.net/viewtopic.php?f=TODO&t=TODO*
   // @include      https://forum.mafiascum.net/viewtopic.php?f=TODO&t=TODO*
Line 74: Line 75:
   // @name          Mafiascum: Ignore
   // @name          Mafiascum: Ignore
   // @namespace    https://www.mafiascum.net/
   // @namespace    https://www.mafiascum.net/
  // @author        northsidegal
   // @description  Ignore a player
   // @description  Ignore a player
   // @include      https://forum.mafiascum.net/viewtopic.php?f=TODO&t=TODO*
   // @include      https://forum.mafiascum.net/viewtopic.php?f=TODO&t=TODO*
Line 100: Line 102:
The site logo is currently disabled, which can sometimes be a bother given that it's useful to click on to return to the board index. This script re-enables it. This is the second version, which allows for custom logos to be used simply by replacing the URL in the "imgsrc" variable.  
The site logo is currently disabled, which can sometimes be a bother given that it's useful to click on to return to the board index. This script re-enables it. This is the second version, which allows for custom logos to be used simply by replacing the URL in the "imgsrc" variable.  


    // ==UserScript==
  // ==UserScript==
    // @name          Mafiascum: Re-Enables Logo
  // @name          Mafiascum: Re-Enables Logo
    // @namespace    https://www.mafiascum.net/
  // @namespace    https://www.mafiascum.net/
    // @description  Brings back the mafiascum logo & allows for custom logos
  // @author        northsidegal
    // @include      https://forum.mafiascum.net/*
  // @description  Brings back the mafiascum logo & allows for custom logos
    // @version      2.3
  // @include      https://forum.mafiascum.net/*
    // ==/UserScript==
  // @version      2.3
  // ==/UserScript==
    
    
    try {
  try {
      // mafSepia logo URL: "./styles/mafsepia/imageset/site_logo.png"
    // mafSepia logo URL: "./styles/mafsepia/imageset/site_logo.png"
      // mafSilver logo URL: "./styles/prosilver/imageset/site_logo.png"
    // mafSilver logo URL: "./styles/prosilver/imageset/site_logo.png"
      // mafTigers logo URL: "./styles/maftigers/imageset/sitelogo.png"
    // mafTigers logo URL: "./styles/maftigers/imageset/sitelogo.png"
    
    
      let imgsrc = "./styles/mafBlack/imageset/site_logo.png"
    let imgsrc = "./styles/mafBlack/imageset/site_logo.png"
        
        
      let desc = document.getElementById("site-description");
    let desc = document.getElementById("site-description");
      var content = "<a href='./index.php' title='Board Index' id='logo'><img src='" + imgsrc + "' alt='' title='' /></a>"
    var content = "<a href='./index.php' title='Board Index' id='logo'><img src='" + imgsrc + "' alt='' title='' /></a>"
        
        
      $(desc.childNodes[1]).replaceWith(content);
    $(desc.childNodes[1]).replaceWith(content);
      //console.log(content);
    //console.log(content);
      //console.log(desc.childNodes[1]);
    //console.log(desc.childNodes[1]);
      //console.log("done");
    //console.log("done");
      }
    }
    catch(e) {
  catch(e) {
      // Do nothing.
    // Do nothing.
      //console.log("failed");
    //console.log("failed");
      console.log(e);
    console.log(e);
    }
  }




[[Category:ScummerSubpages]]
[[Category:ScummerSubpages]]

Revision as of 06:08, 11 July 2020

northsidegal   Played Games   Modded Games   Rulesets   Stats   Setups   Scripts    


Scripts I've made or used for mafiascum. These require the "tampermonkey" browser extension (or something similar). If you use one, I'd really be interested in knowing. It's always nice to see people using your work, so feel free to PM me or something. Or if you prefer you could write something on the guestbook on my main wiki page. Or you could write a heartfelt thank-you note, put it into a bottle and throw it into the ocean, hoping that one day it'll make its way to me. Whatever you prefer.

How to use these

In general, there are two (maybe three) things you need to do, assuming that you already have the browser extension installed.

1. Open the extension dashboard, and click the little plus to make a new script. Then paste in the script.

2. Replace the "TODO"(s) I have there, in the "scum" and "town" lists for the highlighting script and in the username comparison for the ignoring script.

3. Go to page 1 of the thread you want to use it for. Look at the f= and t= numbers – copy those into the script.

That's it! Save the script and it should work from there.

Highlight Posts

Change the "scum" and "town" lists to include flipped players, and this script will highlight those people's posts as red or green. You'll need to specify which thread it's for (keep the asterisk), and it won't work if you click on a post number rather than on a page number.

 // ==UserScript==
 // @name          Mafiascum: Highlight Alignments
 // @namespace     https://www.mafiascum.net/
 // @author        northsidegal
 // @description   Highlight a flipped user's posts red or green depending on alignment
 // @include       https://forum.mafiascum.net/viewtopic.php?f=TODO&t=TODO*
 // @version       1.0
 // ==/UserScript==
 
 try {
    let thread = document.getElementById("page-body");
    let posts = thread.getElementsByClassName("post");
    let scum = ["TODO", "TODO"];
    let town = ["TODO", "TODO"];
    for(var i=0;i<posts.length;i++) {
       let post = posts[i];
       let profile = post.getElementsByClassName("postprofile")[0];
       let usernameLink = profile.getElementsByTagName("a")[0];
       let username = usernameLink.text;
       if(scum.includes(username)){
          post.setAttribute("style", "background-color: #b30000;");
       }
       if(town.includes(username)){
          post.setAttribute("style", "background-color: #009933;");
       }
    }
 } catch(e) {
    // Do nothing.
 }

Ignore A User

Use this to completely hide a specific player's posts. The "foe" feature already serves this purpose in discussion forums, but this works across the entire site, including for mafia games. I'm hesitant to include this because I think it promotes toxicity and I've only ever used it personally to ignore confirmed scum in a theme game, but I'm including it here anyways.

Credit goes to Aster, who created this originally. I have modified it.

 // ==UserScript==
 // @name          Mafiascum: Ignore
 // @namespace     https://www.mafiascum.net/
 // @author        northsidegal
 // @description   Ignore a player
 // @include       https://forum.mafiascum.net/viewtopic.php?f=TODO&t=TODO*
 // @version       1.1
 // ==/UserScript==
 
 try {
    let thread = document.getElementById("page-body");
    let posts = thread.getElementsByClassName("post");
    for(var i=0;i<posts.length;i++) {
       let post = posts[i];
       let profile = post.getElementsByClassName("postprofile")[0];
       let usernameLink = profile.getElementsByTagName("a")[0];
       let username = usernameLink.text;
       if(username == "TODO") {
          let inner = post.getElementsByClassName("inner")[0];
          inner.innerText = "Ignored Post";
       }
    }
 } catch(e) {
    // Do nothing.
 }

The site logo is currently disabled, which can sometimes be a bother given that it's useful to click on to return to the board index. This script re-enables it. This is the second version, which allows for custom logos to be used simply by replacing the URL in the "imgsrc" variable.

 // ==UserScript==
 // @name          Mafiascum: Re-Enables Logo
 // @namespace     https://www.mafiascum.net/
 // @author        northsidegal
 // @description   Brings back the mafiascum logo & allows for custom logos
 // @include       https://forum.mafiascum.net/*
 // @version       2.3
 // ==/UserScript==
 
 try {
   // mafSepia logo URL: "./styles/mafsepia/imageset/site_logo.png"
   // mafSilver logo URL: "./styles/prosilver/imageset/site_logo.png"
   // mafTigers logo URL: "./styles/maftigers/imageset/sitelogo.png"
 
   let imgsrc = "./styles/mafBlack/imageset/site_logo.png"
     
   let desc = document.getElementById("site-description");
   var content = "<a href='./index.php' title='Board Index' id='logo'><img src='" + imgsrc + "' alt= title= /></a>"
     
   $(desc.childNodes[1]).replaceWith(content);
   //console.log(content);
   //console.log(desc.childNodes[1]);
   //console.log("done");
    }
 catch(e) {
   // Do nothing.
   //console.log("failed");
   console.log(e);
 }