Skip to content

Instantly share code, notes, and snippets.

@blewert
Created August 13, 2017 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blewert/e83cdea2d7934d007aa498cbd5c1cde4 to your computer and use it in GitHub Desktop.
Save blewert/e83cdea2d7934d007aa498cbd5c1cde4 to your computer and use it in GitHub Desktop.
My stupid signature for littlewhitey's forum, which confuses the hell out of people.
/**
* blewert
* -----
* sig.src.js
*/
//Find the element containing the name of the person
var greetings = document.getElementsByClassName("greeting");
var username = "";
if(typeof(greetings) === "undefined" || greetings.length === 0)
{
//If we cannot find it, or it doesn't exist, then find existing instances of signatures on one page
var sigs = document.getElementsByClassName("blew-sig");
for(var sig in sigs)
{
//Run through them and set them to "I love [JOKER]SKY"
if(typeof sigs[sig] === "object")
sigs[sig].textContent = "I love [JOKER]SKY";
}
}
else
{
//Remove "Hello"
username = greetings[0].textContent.replace("Hello ", "");
//Get all signatures again
var sigs = document.getElementsByClassName("blew-sig");
//Are they a guest? If so, show default text
if(username === "Guest")
username = "[JOKER]SKY";
for(var sig in sigs)
{
//Run through all signatures and set content to a random signature otherwise
if(typeof sigs[sig] === "object")
sigs[sig].textContent = randomSignature();
}
}
function randomSignature()
{
//A bunch of random signatures
var randSigs =
[
username + " sucks", username + " is a noob", username + " is ez", username + " is easy",
username + "?", username + "? you there?", "I wish " + username + " was here.", username + "!",
username + "..."
];
//Just return a random one
return randSigs[Math.floor(Math.random() * randSigs.length)];
}
//Print out a message
console.log("blewert was here! (" + (new Date()).toGMTString() + ")");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment