Cat Screensaver!

ExonAuto moment

目前為 2023-04-14 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Cat Screensaver!
// @license      MIT
// @namespace    http://tampermonkey.net/
// @version      3.0
// @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 60 seconds*/
var timeTillScreensaverStarts = 60 //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

/*uncaps the imgUpdateSpeed to as fast as your computer can render 2d images*/
var turboMode = false //warning, bright flashing colors

/*changes how fast images are added to the canvas*/
var imgUpdateSpeed = "150" // in miliseconds (1 second = 1000 miliseconds)

/*the text of the little watermark that appears above images*/
var watermark = "PolyJam"

/*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://cdn.discordapp.com/attachments/827543035981332501/1096196780875600083/despiteAllMyRageCat.png',//racing cat
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196781123043519/eppyCat.png',//eepy cat
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196780321931274/angry_cat.png',//angry cat (red)
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196870755319880/JEnUY3nM_t.png',//you have alerted the cat cat
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196937633509386/Jlow2CKl_t.png',//reaching cat
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196869228597299/fYRZWYRs_t.png',//:D Cat (car window cat)
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196939529330858/wakMaWsa_t.png',//maxwell the cat as a 3d model
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196938749202554/NOOHEGOTEATEN.png',//sandwich cat geting squished :(
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196938203930714/maxwell.jpeg',//smug maxwell (i think)
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196870419795968/huhuhuhuuhuhuhuh.png',//huh cat (the what cat not the HUH cat)
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196939034407052/polyjamCat.png',//the polygon cat (i couldn't find their name anywhere)
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196869857738812/getCat.png',//get cat
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196780674257006/boomCat.png',//cat stands infront of a fire
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196871006982304/jinxALotOfCursors.png',//jinx with a lot of cursors
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196871606763570/JinxSomeCursor.png',//jinx with some cursors (still a few but not as many)
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196871912968232/jinxWhiteBackGround.png',//jinx, no cursors, standing in a white room
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196871283822701/jinxOneCursor.png',//jinx, head, only one cursor
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196940020064266/William.png',//w i l l i a m
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196869551575050/get-real-cat-NO-WAY.png',//get real cat
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196939298656326/ThisCatChillinNoWay.png',//chill cat
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196939776806932/whar.jpeg',//sniif sniif
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196779957031013/O-cat.png',//flabberghasted cat
    'https://cdn.discordapp.com/attachments/827543035981332501/1096196870172315728/huhCat.png',//huh 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 = "AFKcanvas"
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 (turboMode == true){updatePos();}
        if (AFK == true && turboMode == true){updateImage()}
        if (includeWatermark == true){ctx.fillText(watermark, XPos, YPos)}
    }
}

function startScreensaver(){
    document.body.appendChild(x);
    updateImage();
    if (consoleLogs == true){
        console.log("started screensaver")
    }
}

function stopScreensaver(){
    if (AFK == false && document.getElementById('AFKcanvas')){document.getElementById("AFKcanvas").remove();}
    if (consoleLogs == true){
        console.log("stopped screensaver")
    }
}

if (turboMode == false){
var amogUs = setInterval(updatePos, imgUpdateSpeed);
var amogUs2 = setInterval(updateImage, imgUpdateSpeed);
}

startScreensaver();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址