Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
NullPounce authored Feb 15, 2023
1 parent d93a1c4 commit f07d078
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 0 deletions.
58 changes: 58 additions & 0 deletions Go-Back-No-Popup.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// ==UserScript==
// @name URL Change Alert
// @namespace https://github.com/NullPounce
// @version 1.0
// @description goes back one page without notice if the user changes urls twice witin 10 seconds.
// @author Your Name
// @match *://*/*
// @grant none
// ==/UserScript==
let urlChanges = 0;
let lastUrl = window.location.href;
let timerId;

setInterval(function() {
if (window.location.href !== lastUrl) {
urlChanges++;
lastUrl = window.location.href;
if (urlChanges >= 2) {
let popup = document.createElement('div');
popup.textContent = 'You have changed URLs 2 times within 10 seconds. You will be redirected to the previous page in 3 seconds...';
popup.style.position = 'fixed';
popup.style.bottom = '50px';
popup.style.left = '50%';
popup.style.transform = 'translate(-50%, 0)';
popup.style.backgroundColor = 'white';
popup.style.padding = '10px';
document.body.appendChild(popup);

let closePopup = function() {
popup.parentNode.removeChild(popup);
clearInterval(timerId);
};

timerId = setInterval(function() {
closePopup();
history.back();
urlChanges = 0;
}, 3000);

popup.addEventListener('click', function() {
closePopup();
history.back();
urlChanges = 0;
});
}
} else {
urlChanges = 0;
if (!timerId) {
timerId = setTimeout(function() {
urlChanges = 0;
timerId = null;
}, 10000);
}
}
}, 5000);



73 changes: 73 additions & 0 deletions Go-Back-URL-Alert-Counter.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// ==UserScript==
// @name URL Change Alert
// @namespace https://github.com/NullPounce
// @version 1.0
// @description Alerts the user if they change URLs 2 times within ten seconds then goes back a page. If there have been 5 popups, a non-closeable popup is displayed for 15 seconds.
// @author NullPounce
// @match *://*/*
// @grant none
// ==/UserScript==

let popupCounter = 0;
let urlChanges = 0;
let lastUrl = window.location.href;
let timerId;
let uncloseablePopup = null;

setInterval(function() {
if (window.location.href !== lastUrl) {
urlChanges++;
lastUrl = window.location.href;
if (urlChanges >= 2) {
popupCounter++; // Increment the counter for each popup displayed
console.log('Popup displayed ' + popupCounter + ' times.');
if (popupCounter >= 5) {
if (!uncloseablePopup) {
uncloseablePopup = document.createElement('div');
uncloseablePopup.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: white;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
`;
const message = document.createElement('p');
message.textContent = '⌚️Time-Out: You are lucky to be doing school at Home on a computer💻. Wait longer before changing pages.';
message.style.cssText = `
font-size: 24px;
text-align: center;
margin: 20px;
`;
uncloseablePopup.appendChild(message);
document.body.appendChild(uncloseablePopup);
setTimeout(() => {
document.body.removeChild(uncloseablePopup);
uncloseablePopup = null;
popupCounter = 0;
}, 15000);
}
} else {
let result = confirm('🤖 You are changing pages too fast. Please slow down and focus 🧠💪');
if (result) {
history.back();
} else {
history.back();
}
urlChanges = 0;
}
}
} else {
urlChanges = 0;
if (!timerId) {
timerId = setTimeout(function() {
urlChanges = 0;
timerId = null;
}, 10000);
}
}
}, 5000);
54 changes: 54 additions & 0 deletions URL-Changer-Alert-Counter.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// ==UserScript==
// @name URL Change Alert
// @namespace https://github.com/NullPounce
// @version 1.0
// @description Alerts the user if they change URLs 2 times within ten seconds. If there have been 5 popups, a non-closeable popup is displayed for 15 seconds.
// @author NullPounce
// @match *://*/*
// @grant none
// ==/UserScript==
let popupCounter = 0;
let uncloseablePopup;
let urlChanges = 0;
let lastUrl = window.location.href;

setInterval(function() {
if (window.location.href !== lastUrl) {
urlChanges++;
lastUrl = window.location.href;
if (urlChanges >= 2) {
popupCounter++;
if (popupCounter === 5) {
if (!uncloseablePopup) {
uncloseablePopup = document.createElement('div');
uncloseablePopup.textContent = '⌚️Time-Out: You are lucky to be doing school at Home on a computer💻. Wait longer before changing pages.';
uncloseablePopup.style.position = 'fixed';
uncloseablePopup.style.top = '0';
uncloseablePopup.style.left = '0';
uncloseablePopup.style.width = '100%';
uncloseablePopup.style.height = '100%';
uncloseablePopup.style.display = 'flex';
uncloseablePopup.style.justifyContent = 'center';
uncloseablePopup.style.alignItems = 'center';
uncloseablePopup.style.backgroundColor = '#ffffff';
uncloseablePopup.style.zIndex = 999999;
document.body.appendChild(uncloseablePopup);
setTimeout(() => {
document.body.removeChild(uncloseablePopup);
uncloseablePopup = null;
popupCounter = 0;
}, 15000);
}
} else {
let result = confirm('🤖 You are changing pages too fast. Please slow down and focus 🧠💪');
console.log('Popup displayed ' + popupCounter + ' times.');
if (!result) {
urlChanges = 0;
}
}
urlChanges = 0;
}
} else {
urlChanges = 0;
}
}, 5000);

0 comments on commit f07d078

Please sign in to comment.