// ==UserScript==
// @name Cat Screensaver!
// @license MIT
// @namespace http://tampermonkey.net/
// @version 2.7
// @description ExonAuto moment
// @match *://*/*
// @icon https://favicon-generator.org/favicon-generator/htdocs/favicons/2023-04-12/025e32544727144aeac3e31ffa5a80b8.ico
// @grant none
// ==/UserScript==
/*___ _ _____ __ __ __ ___ */
/*( _`\ (_ ) (___ ) /'__`\ /' _`\ /'__`\ /'_ )*/
/*| |_) ) _ | | _ _ | | _ _ ___ ___ (_) ) )| ( ) |(_) ) )(_)_) |*/
/*| ,__/'/'_`\ | | ( ) ( ) _ | | /'_` )/' _ ` _ `\ /' / | | | | /' / _(_ < */
/*| | ( (_) ) | | | (_) |( )_| |( (_| || ( ) ( ) | /' /( )| (_) | /' /( )( )_) |*/
/*(_) `\___/'(___)`\__, |`\___/'`\__,_)(_) (_) (_) (_____/'`\___/'(_____/'`\____)*/
/* ( )_| | */
/* `\___/' */
//You can configure the code below, but don't edit the code below the "do not edit line" (unless you know what you are doin)
/*edit this to change how much time it will take to start the screensaver default is 30 seconds*/
var timeTillScreensaverStarts = 15 //in seconds
/*edit this to disable the alert that shows how much time you spent afk after you come back to your compute*/
var alertEnabled = true
/*debug stuff, it just sends stuff to console log that i used in the development process*/
var consoleLogs = false
/*the text of the little watermark that appears above images*/
var watermark = "PolyJam-ExonAuto"
/*adds or removes the watermark from showing up in the screensaver*/
var includeWatermark = true
/* links to the images used in screensaver, currently just the default i made for the jam
DOESNT WORK ON A REGULAR WEBPAGE FIND THE "source" PAGE OF THE IMAGE TO ADD YOUR OWN*/
var imageUrls = [
'https://thumbs2.imgbox.com/c4/a0/VbszZQLG_t.png',//racing cat
'https://thumbs2.imgbox.com/3a/06/E5tfYrBj_t.png',//eepy cat
'https://thumbs2.imgbox.com/f9/cb/BwRKTUrP_t.png',//angry cat (red)
'https://thumbs2.imgbox.com/c4/d4/JEnUY3nM_t.png',//you have alerted the cat cat
'https://thumbs2.imgbox.com/31/1a/Jlow2CKl_t.png',//reaching cat
'https://thumbs2.imgbox.com/e1/0c/fYRZWYRs_t.png',//:D Cat (car window cat)
'https://thumbs2.imgbox.com/28/23/wakMaWsa_t.png',//maxwell the cat as a 3d model
'https://thumbs2.imgbox.com/06/f7/10FxGLOb_t.png',//sandwich cat geting squished :(
'https://thumbs2.imgbox.com/c4/e5/cWS8X4Fu_t.jpg',//smug maxwell (i think)
'https://thumbs2.imgbox.com/3c/f8/SMC73CRg_t.png',//brass microphone maxwell
'https://thumbs2.imgbox.com/62/fb/eIY8aG5h_t.png',//huh cat (the what cat not the HUH cat)
'https://thumbs2.imgbox.com/9e/e5/5smTi8qp_t.png',//the polygon cat (i couldn't find their name anywhere)
'https://thumbs2.imgbox.com/c6/53/beWa97WK_t.png',//get cat
'https://thumbs2.imgbox.com/60/8c/X3KcfdPV_t.png',//cat stands infront of a fire
'https://thumbs2.imgbox.com/a4/4f/ejpyUSNZ_t.png',//jinx with a lot of cursors
'https://thumbs2.imgbox.com/b2/8a/AWtsnDAx_t.png',//jinx with some cursors (still a few but not as many)
'https://thumbs2.imgbox.com/d5/71/HQ6rgqkb_t.png',//jinx, no cursors, standing in a white room
'https://thumbs2.imgbox.com/fc/22/LsFXeReH_t.png',//jinx, head, only one cursor
'https://thumbs2.imgbox.com/f0/19/j8KpWVrD_t.png',//w i l l i a m
'https://thumbs2.imgbox.com/96/2e/CT51PzaM_t.png',//idk how to describe this one
'https://thumbs2.imgbox.com/b8/dd/w4g5LYSz_t.png',//get real cat
'https://thumbs2.imgbox.com/d1/29/u6uqhIJi_t.png',//chill cat
'https://thumbs2.imgbox.com/3c/46/ROrccYeL_t.jpg',//sniif sniif
'https://thumbs2.imgbox.com/47/88/HP7T56nw_t.png',//flabberghasted cat
];
/* ____ ___ _ _ ___ _____ _____ ____ ___ _____ ____ _ ____ _____ _____ _ _ ___ ____ _ ___ _ _ _____ */
/* | _ \ / _ \ | \ | |/ _ \_ _| | ____| _ \_ _|_ _| | _ \ / \ / ___|_ _| |_ _| | | |_ _/ ___| | | |_ _| \ | | ____| */
/* | | | | | | | | \| | | | || | | _| | | | | | | | | |_) / _ \ \___ \ | | | | | |_| || |\___ \ | | | || \| | _| */
/* | |_| | |_| | | |\ | |_| || | | |___| |_| | | | | | __/ ___ \ ___) || | | | | _ || | ___) | | |___ | || |\ | |___ */
/* |____/ \___/ |_| \_|\___/ |_| |_____|____/___| |_| |_| /_/ \_\____/ |_| |_| |_| |_|___|____/ |_____|___|_| \_|_____| */
/* _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ */
/* |_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____| */
/* _ _ _ _ _ _ */
/* _ _ _ __ | | ___ ___ ___ _ _ ___ _ _ | | ___ __ _____ __ __ _| |__ __ _| |_ _ _ ___ _ _ __ _ _ __ ___ __| | ___ (_)_ __ __ _ */
/* | | | | '_ \| |/ _ \/ __/ __| | | | |/ _ \| | | | | |/ / '_ \ / _ \ \ /\ / / \ \ /\ / / '_ \ / _` | __| | | | |/ _ \| | | | / _` | '__/ _ \ / _` |/ _ \| | '_ \ / _` |*/
/* | |_| | | | | | __/\__ \__ \ | |_| | (_) | |_| | | <| | | | (_) \ V V / \ V V /| | | | (_| | |_ | |_| | (_) | |_| | | (_| | | | __/ | (_| | (_) | | | | | (_| |*/
/* \__,_|_| |_|_|\___||___/___/ \__, |\___/ \__,_| |_|\_\_| |_|\___/ \_/\_/ \_/\_/ |_| |_|\__,_|\__| \__, |\___/ \__,_| \__,_|_| \___| \__,_|\___/|_|_| |_|\__, |*/
/* |___/ |___/ |___/ */
// var for checking the user is away
var AFK = false
// checking for user interactions (to stop the screensaver)
document.body.addEventListener('mousemove', resetTheCount);
document.body.addEventListener('scroll', resetTheCount);
document.body.addEventListener('keydown', resetTheCount);
document.body.addEventListener('click', resetTheCount);
document.body.addEventListener('touchstart', resetTheCount);
var increaseAfkTime = setInterval(incrementTheCount, 1000);
var timeSpentAfk = 0
// adds to the timer when needed
function incrementTheCount(){
timeSpentAfk = timeSpentAfk + 1
if(timeSpentAfk >= timeTillScreensaverStarts && AFK == false){
AFK = true
startScreensaver();
window.scrollTo(0, 0);
if(consoleLogs == true){
console.log("Started the screensaver!")
}
}
else{if(consoleLogs == true){
console.log("afk timer: " + timeSpentAfk)
console.log("afk: " + AFK)} //line for showing how much time has passed in the console
}}
//function that triggers when user interacts with the main body of the page
function resetTheCount(){
AFK = false
timeSpentAfk = 0
stopScreensaver(); //also removes the canvas so it doesnt interfere with the page you are currently on
if (consoleLogs == true){
console.log("Reset the count!")
}
if(alertEnabled == true && timeSpentAfk >= timeTillScreensaverStarts){
console.log("You spent " + timeSpentAfk + " seconds afk! thats " + timeSpentAfk/60 + "minutes!")
alert("You spent " + timeSpentAfk + " seconds afk! thats " + timeSpentAfk/60 + " minutes!")
}
}
var XPos = 0
var YPos = 0
var img = new Image()
var pageY = 0
//declaring the canvas
var x = document.createElement("CANVAS");
x.style.left = "0px";
x.style.top = "0px";
x.style.position = "absolute";
x.id = "canvas"
var ctx = x.getContext("2d");
// starts at x=20, y=0
// The end gradient point is at x=220, y=0
const gradient = ctx.createLinearGradient(20, 0, 220, 0);
// Add three color stops
gradient.addColorStop(0, "green");
gradient.addColorStop(0.5, "cyan");
gradient.addColorStop(1, "green");
// Set the fill style and draw a rectangle
ctx.fillStyle = gradient;
ctx.fillRect(20, 20, 200, 100);
ctx.canvas.width = window.innerWidth;
ctx.canvas.height = window.innerHeight;
ctx.font = "25px Times New Roman";
var randomNumber = undefined
// updating XPos and any other ones that may arise...
function updatePos(){
if(AFK == true){
XPos = Math.floor(Math.random() * window.innerWidth) + 1;
YPos = Math.floor(Math.random() * window.innerHeight) + 1;
randomNumber = Math.floor(Math.random() * 2) + 1;
}
//console.log("Current positions ~ " + "xPos = "+ XPos)
}
//updates image that will be shown on the canvas very epic
function updateImage(){
if (AFK == true){
img.src = imageUrls[Math.floor(Math.random() * imageUrls.length)];
if (consoleLogs == true){console.log("img src-> " + img.src + " <-")}
img.style.height = '500px';
img.style.width = '500px';
img.onload = drawScreen
}
}
//draws the images from the updateImage function
function drawScreen(){
if (AFK == true){
ctx.drawImage(img, XPos, YPos);
if (includeWatermark == true){ctx.fillText(watermark, XPos, YPos)}
}
}
//declaring which and when the code will repeat
var updateImageInterval = setInterval(updateImage, 150);
var updateInterval = setInterval(updatePos, 250);
function startScreensaver(){
document.body.appendChild(x);
if (consoleLogs == true){
console.log("started screensaver")
}
}
function stopScreensaver(){
if (AFK == false){document.getElementById("canvas").remove();}
if (consoleLogs == true){
console.log("stopped screensaver")
}
}
startScreensaver();