diff --git a/userscript.js b/userscript.js index 7e96788..20e00f8 100644 --- a/userscript.js +++ b/userscript.js @@ -6,30 +6,789 @@ // @author YumYummity // @match *://*/* // @grant GM_addStyle -// @grant GM_xmlhttpRequest -// @connect raw.githubusercontent.com // ==/UserScript== -(function() { - 'use strict'; - - // Use GM_xmlhttpRequest to fetch the script content - GM_xmlhttpRequest({ - method: 'GET', - url: 'https://raw.githubusercontent.com/YumYummity/COCC/main/code/code.js', - onload: function(response) { - if (response.status === 200) { - // Script content loaded successfully - var scriptContent = response.responseText; - // Use eval to execute the script - eval(scriptContent); - console.log('Script loaded and executed successfully.'); - } else { - console.error('Failed to load script:', response.statusText); - } - }, - onerror: function(error) { - console.error('Failed to load script:', error.statusText); - } - }); -})(); +// CSS for overlay menu +let style = document.createElement('style'); +style.innerHTML = ` + .coc-menu-btn { + position: fixed; + bottom: 20px; + right: 20px; + background-color: #ff4500; + color: #fff; + border-radius: 50%; + padding: 12px; + cursor: pointer; + z-index: 999; + } + + .coc-menu-overlay { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.8); + z-index: 998; + display: flex; + justify-content: center; + align-items: center; + opacity: 0; + pointer-events: none; + transition: opacity 0.3s ease-in-out; + } + + .coc-menu-overlay.active { + opacity: 1; + pointer-events: auto; + } + + #coc-menu { + display: flex; + flex-wrap: wrap; + justify-content: center; + align-items: center; + } + + .coc-menu-item { + background-color: #000; + color: #fff; + padding: 10px 20px; + margin: 10px; + border-radius: 50px; + cursor: pointer; + text-align: center; /* Add this line to center the text */ + } + + .coc-menu-btn { + border-radius: 10px; + } + + /* Add CSS for second row */ + #coc-menu .coc-menu-row { + display: grid; + grid-template-columns: repeat(6, 1fr); + gap: 10px; + margin-top: 10px; + } + + #coc-menu .coc-menu-item:nth-child(n+7) { + margin-top: 10px; + } +`; +document.head.appendChild(style); + +// Check if the window is top level +if (window.self !== window.top) { + return; +} + +// Create Menu Button +let menuBtn = document.createElement('div'); +menuBtn.classList.add('coc-menu-btn'); +menuBtn.textContent = 'Menu'; +document.body.appendChild(menuBtn); + +// Create Menu Overlay +let overlay = document.createElement('div'); +overlay.classList.add('coc-menu-overlay'); +overlay.innerHTML = ` +
+`; +document.body.appendChild(overlay); + +// Add click event listener to Menu Button +menuBtn.addEventListener('click', function() { + overlay.classList.toggle('active'); +}); + +// Function for toggling the menu overlay +function toggleMenu() { + overlay.classList.toggle('active'); +} + +// Function to show error message +function showError(message) { + let overlay = document.createElement("div"); + overlay.style.position = "fixed"; + overlay.style.top = "0"; + overlay.style.left = "0"; + overlay.style.width = "100%"; + overlay.style.height = "100%"; + overlay.style.backgroundColor = "rgba(0, 0, 0, 0.5)"; + overlay.style.zIndex = "9999"; + let errorBox = document.createElement("div"); + errorBox.style.backgroundColor = "#fff"; + errorBox.style.border = "1px solid #000"; + errorBox.style.borderRadius = "5px"; + errorBox.style.padding = "20px"; + errorBox.style.maxWidth = "500px"; + errorBox.style.margin = "0 auto"; + errorBox.style.position = "absolute"; + errorBox.style.top = "50%"; + errorBox.style.left = "50%"; + errorBox.style.transform = "translate(-50%, -50%)"; + let errorMessage = document.createElement("p"); + errorMessage.textContent = message; + errorMessage.style.marginBottom = "20px"; + errorMessage.style.textAlign = "center"; + errorBox.appendChild(errorMessage); + let okayButton = document.createElement("button"); + okayButton.textContent = "Okay"; + okayButton.style.padding = "10px"; + okayButton.style.backgroundColor = "#007bff"; + okayButton.style.color = "#fff"; + okayButton.style.border = "none"; + okayButton.style.borderRadius = "5px"; + okayButton.style.display = "block"; + okayButton.style.margin = "0 auto"; + okayButton.addEventListener("click", function() { + overlay.remove(); + }); + errorBox.appendChild(okayButton); + overlay.appendChild(errorBox); + document.body.appendChild(overlay); +} + +// Function for GradientBG +function gradientBg() { + let colors = [ + '#FF0000', '#FFA500', '#FFFF00', '#00FF00', '#00FFFF', + '#0000FF', '#4B0082', '#EE82EE', '#FF00FF', '#008000', + '#FFD700', '#7FFF00', '#8A2BE2', '#FF1493', '#FF4500', '#2E8B57' + ]; + let i = 0; + let direction = 1; + + let intervalId = setInterval(function() { + let color1 = colors[i]; + let color2 = colors[(i + direction + colors.length) % colors.length]; + + let directions = ['to top', 'to top right', 'to right', 'to bottom right', 'to bottom', 'to bottom left', 'to left', 'to top left']; + let randomDirection = directions[Math.floor(Math.random() * directions.length)]; + + document.body.style.background = `linear-gradient(${randomDirection}, ${color1}, ${color2})`; + + i = (i + direction + colors.length) % colors.length; + }, 500); // Interval time reduced to 500 milliseconds for faster changes + + // Toggle menu after starting GradientBG + toggleMenu(); +} + +// Function for seizure background +function seizureBg() { + toggleMenu(); + let overlay = document.createElement("div"); + overlay.style.cssText = "position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); z-index: 9999;"; + let errorBox = document.createElement("div"); + errorBox.style.cssText = "background-color: #fff; border: 1px solid #000; border-radius: 5px; padding: 20px; max-width: 500px; margin: 0 auto; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);"; + let errorMessage = document.createElement("p"); + errorMessage.textContent = "Are you sure?"; + errorMessage.style.cssText = "margin-bottom: 20px; text-align: center;"; + errorBox.appendChild(errorMessage); + let buttonContainer = document.createElement("div"); + buttonContainer.style.cssText = "display: flex; justify-content: center;"; + let cancelButton = document.createElement("button"); + cancelButton.textContent = "Cancel"; + cancelButton.style.cssText = "padding: 10px; background-color: #007bff; color: #fff; border: none; border-radius: 5px; margin-right: 10px;"; + cancelButton.addEventListener("click", function() { + overlay.remove(); + }); + buttonContainer.appendChild(cancelButton); + let okButton = document.createElement("button"); + okButton.textContent = "Ok"; + okButton.style.cssText = "padding: 10px; background-color: #007bff; color: #fff; border: none; border-radius: 5px;"; + okButton.addEventListener("click", function() { + let colors = ["#000000", "#ffffff"]; + let i = 0; + let direction = 1; + + setInterval(function() { + document.body.style.background = `linear-gradient(to right, ${colors[i]}, ${colors[i + direction]})`; + i = i + direction; + if (i === colors.length - 1 || i === 0) { + direction = -direction; + } + }, 1); + overlay.remove(); + }); + buttonContainer.appendChild(okButton); + errorBox.appendChild(buttonContainer); + overlay.appendChild(errorBox); + document.body.appendChild(overlay); +} + +function rainbowBg() { + toggleMenu(); + let overlay = document.createElement("div"); + overlay.style.cssText = "position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); z-index: 9999;"; + let errorBox = document.createElement("div"); + errorBox.style.cssText = "background-color: #fff; border: 1px solid #000; border-radius: 5px; padding: 20px; max-width: 500px; margin: 0 auto; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);"; + let errorMessage = document.createElement("p"); + errorMessage.textContent = "Set speed for rainbow background."; + errorMessage.style.cssText = "margin-bottom: 20px; text-align: center;"; + errorBox.appendChild(errorMessage); + let sliderContainer = document.createElement("div"); + sliderContainer.style.cssText = "display: flex; align-items: center; justify-content: center;"; + let slider = document.createElement("input"); + slider.type = "range"; + slider.min = 5; + slider.max = 50; + slider.value = 20; + slider.style.cssText = "flex-grow: 1; margin-right: 10px;"; + let inputBox = document.createElement("input"); + inputBox.type = "number"; + inputBox.min = 5; + inputBox.max = 50; + inputBox.value = 20; + inputBox.style.cssText = "width: 50px;"; + slider.addEventListener("input", function() { + inputBox.value = slider.value; + }); + inputBox.addEventListener("change", function() { + let inputValue = parseInt(inputBox.value); + if (inputValue < 5) { + inputBox.value = 5; + } else if (inputValue > 50) { + inputBox.value = 50; + } + slider.value = inputBox.value; + }); + sliderContainer.appendChild(slider); + sliderContainer.appendChild(inputBox); + errorBox.appendChild(sliderContainer); + let buttonContainer = document.createElement("div"); + buttonContainer.style.cssText = "display: flex; justify-content: center; margin-top: 20px;"; + let cancelButton = document.createElement("button"); + cancelButton.textContent = "Cancel"; + cancelButton.style.cssText = "flex-grow: 1; padding: 10px; background-color: #007bff; color: #fff; border: none; border-radius: 5px; margin-right: 10px;"; + cancelButton.addEventListener("click", function() { + overlay.remove(); + }); + buttonContainer.appendChild(cancelButton); + let okButton = document.createElement("button"); + okButton.textContent = "Ok"; + okButton.style.cssText = "flex-grow: 1; padding: 10px; background-color: #007bff; color: #fff; border: none; border-radius: 5px; margin-left: 10px;"; + okButton.addEventListener("click", function() { + let hue = 0; + let speed = parseInt(inputBox.value); + setInterval(() => { + hue = (hue + 1) % 360; + document.body.style.backgroundColor = `hsl(${hue}, 100%, 50%)`; + }, speed); + overlay.remove(); + }); + buttonContainer.appendChild(okButton); + errorBox.appendChild(buttonContainer); + overlay.appendChild(errorBox); + document.body.appendChild(overlay); +} + + +// Function to send a custom alert +function customAlert() { + toggleMenu(); + let style = document.createElement("style"); + style.innerHTML = ` + .coc-alert-box { + background-color: #fff; + padding: 20px; + border-radius: 10px; + max-width: 300px; + text-align: center; + } + + .coc-alert-input { + width: 100%; + padding: 10px; + margin-bottom: 10px; + border-radius: 5px; + box-sizing: border-box; /* Add this property */ + } + + .coc-alert-buttons { + display: flex; + justify-content: center; + } + + .coc-alert-ok, + .coc-alert-cancel { + background-color: #000; + color: #fff; + padding: 10px 20px; + margin: 0 10px; + border-radius: 50px; + cursor: pointer; + } + `; + document.head.appendChild(style); + let overlay = document.createElement("div"); + overlay.classList.add("coc-menu-overlay"); + let alertBox = document.createElement("div"); + alertBox.classList.add("coc-alert-box"); + let title = document.createElement("h2"); + title.textContent = "Custom Alert"; + alertBox.appendChild(title); + let input = document.createElement("input"); + input.type = "text"; + input.classList.add("coc-alert-input"); + alertBox.appendChild(input); + let buttons = document.createElement("div"); + buttons.classList.add("coc-alert-buttons"); + let okButton = document.createElement("button"); + okButton.textContent = "Send Alert"; + okButton.classList.add("coc-alert-ok"); + okButton.addEventListener("click", function() { + let message = input.value; + overlay.classList.remove("active"); + setTimeout(function() { + if (message) { + alert(message); + } + overlay.remove(); + }, 300); + }); + buttons.appendChild(okButton); + let cancelButton = document.createElement("button"); + cancelButton.textContent = "Cancel"; + cancelButton.classList.add("coc-alert-cancel"); + cancelButton.addEventListener("click", function() { + overlay.classList.remove("active"); + setTimeout(function() { + overlay.remove(); + }, 300); + }); + buttons.appendChild(cancelButton); + alertBox.appendChild(buttons); + overlay.appendChild(alertBox); + document.body.appendChild(overlay); + setTimeout(function() { + overlay.classList.add("active"); + input.focus(); + }, 100); +} + +// Custom Script Popup +function runScript() { + toggleMenu(); + let style = document.createElement("style"); + style.innerHTML = ` + .coc-script-box { + background-color: #fff; + padding: 20px; + border-radius: 10px; + max-width: 600px; + width: 70%; + text-align: center; + margin: 0 auto; + box-sizing: border-box; + } + + .coc-script-input { + width: 100%; + height: 150px; + padding: 10px; + margin-bottom: 10px; + border-radius: 5px; + box-sizing: border-box; + } + + .coc-script-buttons { + display: flex; + justify-content: center; + } + + .coc-script-run, + .coc-script-cancel { + background-color: #000; + color: #fff; + padding: 10px 20px; + margin: 0 10px; + border-radius: 50px; + cursor: pointer; + } + + .coc-error-box { + background-color: #fff; + padding: 20px; + border-radius: 10px; + max-width: 400px; + width: 70%; + text-align: center; + margin: 0 auto; + box-sizing: border-box; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + z-index: 9999; + } + + .coc-error-message { + margin-bottom: 10px; + } + + .coc-error-okay { + background-color: #000; + color: #fff; + padding: 10px 20px; + margin-top: 10px; + border-radius: 50px; + cursor: pointer; + } + `; + document.head.appendChild(style); + let overlay = document.createElement("div"); + overlay.classList.add("coc-menu-overlay"); + let scriptBox = document.createElement("div"); + scriptBox.classList.add("coc-script-box"); + let title = document.createElement("h2"); + title.textContent = "Custom Script"; + scriptBox.appendChild(title); + let input = document.createElement("textarea"); + input.classList.add("coc-script-input"); + scriptBox.appendChild(input); + let buttons = document.createElement("div"); + buttons.classList.add("coc-script-buttons"); + let runButton = document.createElement("button"); + runButton.textContent = "Run"; + runButton.classList.add("coc-script-run"); + runButton.addEventListener("click", function() { + let script = input.value; + if (!script.trim()) { + // Check if input is empty or full of whitespaces + overlay.classList.remove("active"); + setTimeout(function() { + overlay.remove(); + }, 300); + showError("Input can't be empty"); + } else { + overlay.classList.remove("active"); + setTimeout(function() { + try { + eval(script); + } catch (error) { + console.error("Error in custom script:", error); + } + overlay.remove(); + }, 300); + } + }); + buttons.appendChild(runButton); + let cancelButton = document.createElement("button"); + cancelButton.textContent = "Cancel"; + cancelButton.classList.add("coc-script-cancel"); + cancelButton.addEventListener("click", function() { + overlay.classList.remove("active"); + setTimeout(function() { + overlay.remove(); + }, 300); + }); + buttons.appendChild(cancelButton); + scriptBox.appendChild(buttons); + overlay.appendChild(scriptBox); + document.body.appendChild(overlay); + setTimeout(function() { + overlay.classList.add("active"); + overlay.appendChild(scriptBox); + document.body.appendChild(overlay); + setTimeout(function() { + overlay.classList.add("active"); + }, 100); + }, 100); +} + +// Function for Reload page with custom confirmation popup +function reloadPage() { + toggleMenu(); + // Create overlay element + let overlay = document.createElement("div"); + overlay.style.position = "fixed"; + overlay.style.top = "0"; + overlay.style.left = "0"; + overlay.style.width = "100%"; + overlay.style.height = "100%"; + overlay.style.backgroundColor = "rgba(0, 0, 0, 0.5)"; + overlay.style.display = "flex"; + overlay.style.alignItems = "center"; + overlay.style.justifyContent = "center"; + overlay.style.zIndex = "9999"; // Set z-index to a higher value + + // Create confirmation popup element + let popup = document.createElement("div"); + popup.style.backgroundColor = "#fff"; + popup.style.padding = "20px"; + popup.style.borderRadius = "10px"; + popup.style.textAlign = "center"; + popup.innerHTML = ` +