// ==UserScript==
// @name Auto Unpause Acellus Videos
// @namespace https://greasyfork.org/en/users/1291009
// @version 2.0
// @description Unpauses the video when changing tabs on Acellus ;)
// @author BadOrBest
// @license MIT
// @icon https://www.google.com/s2/favicons?sz=64&domain=acellus.com
// @match https://admin192c.acellus.com/student/*
// @grant none
// @grant GM_addStyle
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM.registerMenuCommand
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
let isTabFocused = true;
let shouldTogglePlayer = true;
let tabChangeCount = parseInt(localStorage.getItem('tabChangeCount')) || 0;
let lastPromptTime = parseInt(localStorage.getItem('lastPromptTime')) || 0;
let selectedTone = localStorage.getItem('selectedTone') || 'Studious'; // Default to Studious tone
let isMonitoring = true; // Flag to control monitoring
// Tones with 100 variations each
const tones = {
"Excited": ["Hey! Welcome back! Your video is now playing! 🎉", "Awesome! Guess what? The video is playing now! 📽️", "Woohoo! You’re back, and the video is rolling! 🍿", "Let’s go! Your video is live now! 🎬", "Oh hey! Great to see you! The video is playing! 🎥", "Yay! We’re rolling your video again! 🎊", "Guess what? Welcome back! The video is on! 🥳", "Surprise! Your video is playing right now! 🎡", "Boom! We’re watching the video! 🔥", "Awesome stuff! Video coming back up! 🎤", "Look at that! Welcome back, the video is resuming! 📺", "Oh wow! Your video is playing now! 🎇", "Let’s go! The video is live again! 🎦", "Your video is on! Time for fun again! 🎞️", "Here we go! Playing your video again! 🎢", "We’re back! Ready for your video? 🎊", "Get ready! Your video is playing now! 🎠", "Can’t wait! The video is rolling! 📸", "It’s showtime! Your video is live! 🎆", "Hey again! Here’s your video back! 🍿", "Video coming up right now! Let’s enjoy! 🎤", "Great to see you! Playing your video again! 🎸", "The wait is over! Your video is here! 🎉", "Yay! Let’s watch this video! 🌟", "Exciting stuff ahead! Video is playing now! 🎯", "It’s happening! Your video is on! 🎬", "Woohoo! The video’s back on! 🎡", "Guess what? Your video’s on! 🌈", "Fantastic! Your video is playing! 🎥", "Here it is! Video’s playing now! 🎶", "Let’s get back to it! Playing video now! 🎥", "Are you ready? Your video is playing! 🎪", "Surprise! Your video is playing again! 🎉", "Back so soon? Your video is live! 🎈", "Here we go! Video is playing again! 🎤", "Let’s get back to the fun! Playing video! 🌠", "You’re back! The video is rolling again! 🍿", "Playing video again for you! 🎦", "Let’s do this! Video is playing now! 🎸", "Amazing! Your video is on! 🎭", "Boom! The video is back on! 🎤", "Woohoo! Ready for more video? 🌟", "Let’s go! Video’s playing now! 🎊", "Great to see you again! Video’s rolling! 🎇", "Back at it! The video is playing now! 🎞️", "Can’t wait! Playing video again! 🎬", "Back to the action! Your video is on! 🎡", "Let’s roll! Video playing now! 📺", "Guess what? The video is back! 🎯", "You’re back! Playing video for you! 🎥", "Boom! Let’s watch that video again! 🎆", "Fantastic! Your video is on! 🎉", "Ready for action? Video is playing! 🎠", "Surprise! Playing video again! 🎤", "Get ready! The video is rolling! 🍿", "Awesome stuff! Video’s back on! 🎊", "Let’s go! Your video is playing! 🎸", "Amazing! Let’s continue the video! 🎦", "Boom! The video is playing! 🌈", "Great to see you! Video’s playing again! 🎥", "Back again? Let’s watch that video! 🎇", "Fantastic! Your video is back! 🎊", "We’re back! Playing video now! 🎬", "Ready to roll? Video is playing! 🍿", "Woohoo! Let’s keep that video rolling! 🎠", "Guess what? Your video is playing again! 🎉"],
"Depressed": ["Ugh... you’re back... the video is still playing... 😞", "Well, I guess the video will continue... 📼", "Sigh... welcome back... Playing the video... 😔", "Oh... you're back... fine, the video is playing. 😐", "Still here, huh? Video is playing again... 😕", "Let's just get through this... 🎦", "I guess it's time for the video again... 😶", "You’re still watching? Playing the video... 😩", "Why is this still going... 😓", "Here we go... the video continues... 🥱", "Do we really need to do this? Video on... 😐", "Great, more video... 😑", "The video’s back... yay... 😔", "We’re still doing this? Fine, playing video... 😒", "Sigh... here comes the video... 😶", "Why does this never end? Playing video... 😔", "Oh no... more video... 😩", "Guess I’ll start the video... again... 😕", "Another video? Sigh... playing now... 📼", "Can we just stop this? Fine, video’s playing... 😐", "Still here? Playing video... 😕", "Not again... the video is playing... 😩", "Why is this happening? Playing video... 😣", "Great, more video... 🥱", "The video’s still going... Sigh... 😔", "Back again? Fine, playing the video... 😐", "Another one? Playing video... 😕", "I guess we’re still watching... Playing video... 😶", "Here we go again... Sigh... playing video... 😩", "Do we really need this? Video’s playing... 😒", "The video continues... hooray... 😔", "Well... I guess we’re doing this... Playing video... 😑", "Can’t we stop? Playing video... 😕", "Ugh... it’s still going... 😒", "This video never ends... Playing now... 😔", "Sigh... more video... fine, playing... 😶", "Oh no... here comes the video... 😩", "Guess it’s time for more... Playing video... 😔", "Do we really need more of this? Playing video... 😒", "More video? Sigh... it’s playing... 😕", "Still watching? Here comes more... 😣", "Another one? Great... Playing video... 😩", "Can we stop? No? Fine... Playing video... 😒", "Oh joy... more video... 😔", "Sigh... here comes more... 😩", "We’re still doing this? Fine, video is playing... 😒", "This never ends... Playing video... 😔", "More of this? Okay... Playing video... 😣", "Do we have to? Yes? Fine... Playing video... 😒", "Still here? Okay, playing more video... 😶", "Sigh... another one... Playing video... 😔", "More video... great... Playing now... 😕", "This is never-ending... Playing video... 🥱", "Still going... Sigh... Playing video... 😣", "Oh no... more of this... Fine, playing... 😔", "More video... yay... Playing now... 😩", "I guess we’ll continue... Playing video... 😒", "Still watching? Fine... Playing video... 😔", "Do we need more? Sigh... Playing video... 😩", "Here we go again... fine, video is playing... 😶"],
"Angry": ["Welcome back! Video’s still on! 😡", "Ugh, let’s just get this over with... 😤", "Seriously? Playing the same video... 😠", "Why is this still happening? Video is on... 😤", "Unbelievable! Video is still playing! 😡", "Get ready... here comes the same video again... 😠", "This is so annoying! Still watching this video... 😤", "What a waste of time! Video is still on! 🤬", "Can we stop this video already? 😠", "Not again! The same video is back on! 😡", "Why is this still going? Just playing the video! 😤", "Great, more of this nonsense... 😡", "Why is this happening again? Just play the video! 🤬", "I’m done with this! Video is playing... 😤", "Here we go again! The same video is still playing... 😠", "Oh, joy... more of this video... 😡", "Are you serious? This video is still playing? 😤", "Why do we have to keep watching? Video is still on! 😠", "Here comes the same old video... 😤", "Why won’t this just end? Video is still playing! 😡", "Let’s wrap this up already! Video is on... 🤬", "Why is this dragging on? Video is still going... 😡", "Oh great! More video! Just what I wanted... 😠", "Seriously? Back to this video? 😡", "This is ridiculous! Still playing video... 😠", "Here we go again... just another video! 😡", "What’s the point? Video is still running... 😤", "More of this junk? Fine, video is playing... 😡", "Great... just great! The video continues... 😠", "Unbelievable! More video? Just stop it! 🤬", "Why won’t this video end? I’m done! 😡", "Here we go again... the same video... 😤", "This is getting ridiculous! Video is on! 😡", "I can’t believe this! The same video is playing! 😠", "Can’t we change it up? Video is still going... 😤", "Why are we still here? Video is playing... 😡", "More of this? Really? Video is still on! 😠", "This is so frustrating! Playing the video again! 🤬", "Let’s just finish this! Video is still on! 😡", "Why are we doing this again? Video is still playing! 😠", "Another round of this? Ugh... Playing video! 😤", "Here we go again... Video is still on! 😡", "Why do we have to keep doing this? Video is playing... 😤"],
"Studious": ["Welcome back! The study video is now playing! 📚", "Great to see you! Your study video is on! 🎓", "Hey! The educational video is playing now! 📝", "Let’s dive into learning! Your video is playing! 🎥", "Back to studying! The video is live! 📖", "Good to have you back! Video is about to start! 🔍", "Ready to learn? Your study video is playing! 🎉", "Welcome back! Let’s get to the study video! 📘", "Here we go! The educational video is rolling! 🎬", "Fantastic! Your study video is live now! 📚", "Awesome! Time for some learning! 🎓", "Let’s get back to it! The video is playing! 📖", "Great to see you! Ready for the study video? 🎥", "Let’s dive in! Your educational video is on! 📝", "Here we go! The study video is starting! 🎓", "Back to learning! Your video is playing now! 📚", "Awesome! The study session is on! 📘", "Let’s keep learning! The video is rolling! 🎬", "Time to study! Your educational video is live! 🔍", "Great! The study video is now playing! 🎉", "Welcome back! Learning time! 🎓", "Let’s jump into the video! Educational content ahead! 📖", "Back at it! Your study video is on! 🎥", "Time to focus! The study video is playing! 📘", "Let’s learn together! Your video is rolling! 🎓", "Ready to study? The video is here! 📚", "Fantastic! The study session is on! 🎉", "Let’s get started! Your educational video is playing! 🎓", "Welcome back! Time for some study time! 📖", "Great! The video is live now! 🎥", "Let’s dive into this! The study video is on! 📘", "Awesome! Let’s keep learning! 🎓", "Back to it! The educational video is rolling! 🎬", "Time to study! Your video is playing now! 📚", "Fantastic! Here comes the educational video! 🎉", "Let’s get back to learning! The video is on! 📖", "Ready for some knowledge? Your video is live! 🎥", "Let’s jump back into the study! The video is rolling! 📘", "Here we go! Let’s learn something new! 🎓"]
};
function getRandomGreeting() {
const randomIndex = Math.floor(Math.random() * tones[selectedTone].length);
return tones[selectedTone][randomIndex];
}
function showToneSelectionGUI() {
const toneGUI = document.createElement('div');
toneGUI.id = 'toneSelectionGUI';
toneGUI.style = `
position: fixed; top: 20%; left: 50%; transform: translate(-50%, -50%);
background-color: #fff; border: 2px solid #007bff; padding: 20px;
border-radius: 10px; box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
z-index: 10000; text-align: center; color: #333; opacity: 0;
transition: opacity 0.5s ease-out;
`;
const title = document.createElement('p');
title.textContent = "Select Your Preferred Tone or Disable Messages";
title.style.color = '#007bff';
title.style.fontWeight = 'bold';
title.style.marginBottom = '10px';
toneGUI.appendChild(title);
const toneOptions = ["Excited", "Depressed", "Angry", "Studious", "No Messages"];
toneOptions.forEach(tone => {
const button = document.createElement('button');
button.textContent = tone;
button.style = 'margin: 5px; padding: 10px 15px; border-radius: 5px; border: none; background-color: #007bff; color: #fff; cursor: pointer;';
button.onclick = function() {
selectedTone = (tone === 'No Messages') ? null : tone;
localStorage.setItem('selectedTone', selectedTone);
document.body.removeChild(toneGUI);
};
toneGUI.appendChild(button);
});
document.body.appendChild(toneGUI);
setTimeout(() => toneGUI.style.opacity = '1', 100);
}
function showWelcomeBackGUI() {
if (!selectedTone) return;
tabChangeCount++;
localStorage.setItem('tabChangeCount', tabChangeCount);
const existingGUI = document.getElementById('welcomeBackGUI');
if (existingGUI) existingGUI.remove();
const welcomeBackGUI = document.createElement('div');
welcomeBackGUI.id = 'welcomeBackGUI';
welcomeBackGUI.style = `
position: fixed; top: 10%; right: 20px; background-color: #fff;
border: 2px solid #007bff; padding: 15px; border-radius: 10px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1); z-index: 10000;
text-align: center; color: #333; opacity: 0;
transition: opacity 0.5s ease-out, transform 0.5s ease-in-out;
cursor: pointer; transform: translateX(100px);
`;
const greetingText = document.createElement('p');
greetingText.textContent = getRandomGreeting();
greetingText.style.color = '#007bff';
greetingText.style.fontWeight = 'bold';
welcomeBackGUI.appendChild(greetingText);
welcomeBackGUI.onclick = function() {
welcomeBackGUI.style.opacity = '0';
setTimeout(() => document.body.removeChild(welcomeBackGUI), 500);
};
setTimeout(() => {
welcomeBackGUI.style.opacity = '0';
setTimeout(() => document.body.removeChild(welcomeBackGUI), 500);
}, 2500);
document.body.appendChild(welcomeBackGUI);
setTimeout(() => {
welcomeBackGUI.style.opacity = '1';
welcomeBackGUI.style.transform = 'translateX(0)';
}, 100);
}
// Create PiPController to handle Picture-in-Picture functionality
const PiPController = {
isInPiPMode: false,
enter(mediaElements) {
console.log('Attempting to enter PiP mode...');
if (document.pictureInPictureEnabled && mediaElements.length > 0) {
mediaElements.forEach(mediaElement => {
if (mediaElement instanceof HTMLVideoElement && mediaElement.readyState >= 2 && !this.isInPiPMode) {
mediaElement.requestPictureInPicture()
.then(() => {
this.isInPiPMode = true;
console.log('Entered PiP mode successfully.');
})
.catch(error => console.error('Error entering PiP mode:', error));
}
});
}
},
exit() {
if (document.pictureInPictureElement) {
document.exitPictureInPicture()
.then(() => {
this.isInPiPMode = false;
console.log('Exited PiP mode successfully.');
})
.catch(error => console.error('Error exiting PiP mode:', error));
}
},
unpauseMedia(mediaElements) {
mediaElements.forEach(mediaElement => {
if (document.hidden && !isTabFocused && mediaElement.paused && !mediaElement.getAttribute('data-user-paused')) {
mediaElement.play();
console.log('Unpaused media element.');
}
});
},
handleVisibilityChange(mediaElements) {
if (document.hidden && !isTabFocused) {
this.unpauseMedia(mediaElements);
if (shouldTogglePlayer && !this.isInPiPMode) {
this.enter(mediaElements);
}
} else if (isTabFocused && this.isInPiPMode) {
this.exit();
}
}
};
function handleTabChange() {
const mediaElements = document.querySelectorAll('video, audio, .plyr');
PiPController.handleVisibilityChange(mediaElements);
}
// Start monitoring for tab changes
const monitoringInterval = setInterval(() => {
if (isMonitoring) {
handleTabChange();
}
}, 1000); // Check every second
// Register menu commands and add event listeners
GM.registerMenuCommand("Change Message Tone", showToneSelectionGUI);
GM.registerMenuCommand("Toggle Auto Unpause", () => {
isMonitoring = !isMonitoring;
alert(`Auto Unpauser is now ${isMonitoring ? "enabled" : "disabled"}.`);
});
document.addEventListener('visibilitychange', handleTabChange);
window.addEventListener('focus', () => {
isTabFocused = true;
showWelcomeBackGUI();
});
window.addEventListener('blur', () => isTabFocused = false);
// Daily reset logic
const lastVisit = localStorage.getItem('lastVisit');
const today = new Date().toISOString().slice(0, 10);
if (lastVisit !== today) {
localStorage.setItem('tabChangeCount', '0');
localStorage.setItem('lastVisit', today);
}
})();