NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Seedbox Copy Button
// @namespace https://rapidseedbox.example
// @version 1.6
// @description Adds a copy button to the info popup on Seedbox site, removes the word "console" from copied data, and shows appropriate notifications on success or failure.
// @author NiGHTCUM
// @license MIT
// @match https://rapidseedbox72282-rt.swift-008.seedbox.vip/
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Log when the script starts
console.log("Script started.");
// Function to add the copy button
function addCopyButton() {
console.log("Attempting to add the copy button.");
// Check if the "Hide" button exists
const hideButton = document.querySelector('.Button[value="Hide"]');
if (!hideButton) {
console.log("Hide button not found.");
return;
}
// Check if the copy button already exists
if (document.querySelector('#copyButton')) {
console.log("Copy button already exists.");
return;
}
console.log("Creating the copy button.");
// Create the copy button
const copyButton = document.createElement('button');
copyButton.id = 'copyButton';
copyButton.textContent = 'Copy';
copyButton.style.marginRight = '10px'; // Add space between buttons
// Add click event to copy content
copyButton.addEventListener('click', function() {
console.log("Copy button clicked.");
const popupContent = document.querySelector('#tskConsole-header.dlg-header').nextElementSibling;
if (popupContent) {
// Check if popup content is empty
let textToCopy = popupContent.innerText.replace(/console/gi, '').trim();
if (textToCopy) {
// Copy the non-empty content
navigator.clipboard.writeText(textToCopy).then(function() {
console.log('Media-info Copied');
showNotification('Media-info Copied', 'green'); // Show green notification on success
}).catch(function(err) {
console.error('Failed to copy Media-info', err);
showNotification('Failed to copy Media-info', 'red'); // Show red notification on error
});
} else {
// Show notification if no media info is found
console.log('No Media-info found.');
showNotification('No Media-info found.', 'red'); // Show red notification if no content
}
} else {
console.log('Popup content not found.');
showNotification('No Media-info found.', 'red'); // Show red notification if no content
}
});
console.log("Inserting the copy button before the hide button.");
// Insert the copy button before the hide button
hideButton.parentNode.insertBefore(copyButton, hideButton);
console.log("Copy button added successfully.");
}
// Function to show a notification at the top-right corner
function showNotification(message, color) {
// Create the notification element
const notification = document.createElement('div');
notification.textContent = message;
notification.style.position = 'fixed';
notification.style.top = '10px';
notification.style.right = '10px';
notification.style.padding = '10px';
notification.style.backgroundColor = color; // Set background color based on parameter
notification.style.color = 'white';
notification.style.borderRadius = '5px';
notification.style.zIndex = '9999';
notification.style.fontSize = '14px';
notification.style.boxShadow = '0px 0px 10px rgba(0, 0, 0, 0.5)';
// Append the notification to the body
document.body.appendChild(notification);
// Remove the notification after 1 second
setTimeout(() => {
notification.remove();
}, 1000);
}
// Mutation observer to detect changes in the DOM
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length > 0) {
console.log("DOM mutation detected.");
addCopyButton();
}
});
});
// Start observing the document for changes
observer.observe(document.body, { childList: true, subtree: true });
console.log("Mutation observer started.");
})();