Spooky Skeletons

Something serious.

audio.mp3
  1. open browser console
  2. paste code (see below)
  3. press enter
  4. close console
  5. press spooky button on/off
JavaScript:
let isSpooking = false;
let currentSkelleton = null;
let newStyle = null;
let skeletton_animation = [
    "https://www.hiveworkshop.com/attachments/skelleton-1-gif.307520/",
    "https://www.hiveworkshop.com/attachments/skeletton-2-gif.307521/",
    "https://www.hiveworkshop.com/attachments/skeletton-3-gif.307522/",
    "https://www.hiveworkshop.com/attachments/skeletton-4-gif.307523/",
    "https://www.hiveworkshop.com/attachments/skeletton-5-gif.307524/",
    "https://www.hiveworkshop.com/attachments/skeletton-6-gif.307525/",
    "https://www.hiveworkshop.com/attachments/skeletton-7-gif.307526/",
    "https://www.hiveworkshop.com/attachments/skeletton-8-gif.307527/",
    "https://www.hiveworkshop.com/attachments/skeletton-9-gif.307528/",
];

let setRandomBackground = function(skeletton_array) {
    let index = 1 + Math.floor(Math.random() * skeletton_array.length - 1);
    document.body.style.background = "url('" + skeletton_array[index] + "')";
};

// Add div to HTML
let addDivElement = function(htmlCode, element) {
    let divContainer = document.createElement("div");
    divContainer.innerHTML = htmlCode;
    divContainer.style.position = "relative";
    divContainer.style.zIndex = "%";
    element.appendChild(divContainer);
};

// Add style to head
let addStyleElement = function(styleString) {
    let css = styleString;
    let head = document.head || document.getElementsByTagName('head')[0];
    let style = document.createElement('style');
    style.type = 'text/css';
    style.appendChild(document.createTextNode(css));
    head.appendChild(style);
    return style;
};

let toggleSpook = function() {
    isSpooking = !isSpooking;
    if(isSpooking) {
        setRandomBackground(skeletton_animation);
        currentSkelleton = setInterval(function() { setRandomBackground(skeletton_animation); }, 5 * 1000);
        newStyle = addStyleElement("div.item-container { background: #161618BB !important; } #footer-links { background: #161618BB !important; }");
        toggleButton.src = "https://www.hiveworkshop.com/attachments/button-2-png.307519/";
        musicPlayer.play();
    }
    else {
        clearInterval(currentSkelleton);
        document.body.style.background = "black";
        newStyle.remove();
        musicPlayer.pause();
        toggleButton.src = "https://www.hiveworkshop.com/attachments/button-1-png.307518/";
    }
}

addDivElement("<audio loop controls id=\"spookydoot\" style=\"display: none;\"><source src=\"https://www.hiveworkshop.com/attachments/andrew-gold-spooky-scary-skeletons-mp3.307517/\" type=\"audio/mpeg\"></audio>", document.body);
let musicPlayer = document.getElementById("spookydoot");
let toggleButton = document.createElement("img");
toggleButton.src = "https://www.hiveworkshop.com/attachments/button-1-png.307518/";
toggleButton.style = "position: fixed; top: 222.00px; left: 38.00px; width: 145px;";
toggleButton.addEventListener("click", toggleSpook);
document.body.appendChild(toggleButton);
 

Attachments

  • -.mp3
    112.5 KB · Views: 74

pyf

pyf

Level 29
Joined
Mar 21, 2016
Messages
2,881
a8516d8c63a51718dab2be0fa1d7c7c4.jpg
 
Top