Skip to content

Instantly share code, notes, and snippets.

@antonhedstrom
Last active April 9, 2024 21:24
Show Gist options
  • Select an option

  • Save antonhedstrom/95855a2766160cd1b00d208f0dfec6fa to your computer and use it in GitHub Desktop.

Select an option

Save antonhedstrom/95855a2766160cd1b00d208f0dfec6fa to your computer and use it in GitHub Desktop.
Scary prank
// Install Chrome extension (in order to execute after page reloads as well):
// https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija
// After installation, add script and right the icon and choose 'Hide in Chrome Menu'.
(function() {
var imgUrl = 'http://1.bp.blogspot.com/-GGQgBdfMYJ0/Tw82LPGILnI/AAAAAAAABIw/V_1hnWbKgRw/s1600/scary_05.gif';
var soundUrl = 'http://www.szworld.net/scary-sounds/downloader.php?file=audio/final-scream.mp3';
var defaultDelay = 3 * 60; // secs
var duration = 2000; // msec
var alertText = ' ⚠ ALWAYS LOCK IT ⚠ ';
var showAlertTime = 5; // secs (set to 0 for not showing at all)
preloadImage(imgUrl);
var sound = loadSound(soundUrl);
activate();
// Expose run
window.run = activate;
function activate(delay, url) {
delay = delay || defaultDelay;
setTimeout(function() {
doit(url || imgUrl);
}, delay * 1000);
}
function doit(url) {
var wrapper = document.createElement("footer");
wrapper.setAttribute('style', `
display: none;
background-image: url(${url});
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
`);
var textElement = document.createElement("div");
textElement.innerHTML = alertText;
textElement.setAttribute('style', `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
margin-top: 30%;
text-align: center;
font-size: 6.5em;
color:#fff;
letter-spacing:-7px;
font-weight:500;
text-transform:uppercase;
animation:blur .75s ease-out infinite;
text-shadow:0px 0px 5px red, 0px 0px 7px red;
`)
var customStyling = document.createElement("style");
customStyling.setAttribute('style', `
@keyframes blur{
from{text-shadow:
0px 0px 10px #fff,
0px 0px 10px #fff,
0px 0px 25px #fff,
0px 0px 25px #fff,
0px 0px 25px #fff,
0px 0px 25px #fff,
0px 0px 25px #fff,
0px 0px 25px #fff,
0px 0px 50px #fff,
0px 0px 50px #fff,
0px 0px 50px #7B96B8,
0px 0px 150px #7B96B8,
0px 10px 100px #7B96B8,
0px 10px 100px #7B96B8,
0px 10px 100px #7B96B8,
0px 10px 100px #7B96B8,
0px -10px 100px #7B96B8,
0px -10px 100px #7B96B8;
}}
`)
document.head.append(customStyling)
document.body.append(wrapper);
wrapper.style.display = 'block';
sound.play();
setTimeout(function() {
wrapper.remove();
sound.pause();
if ( showAlertTime ) {
document.body.append(textElement);
setTimeout(function() {
textElement.remove();
}, showAlertTime * 1000);
}
}, duration);
}
function preloadImage(url) {
var img = new Image();
img.src = url;
}
function loadSound(url) {
var audio = new Audio(url);
return audio;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment