您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds draggable buttons to enable text selection and get cookies of the current page
// ==UserScript== // @name Enable Text Selection and Get Cookies // @namespace https://greasyfork.org/users/296362 // @version 24.09.12.0 // @author Lancelotly.Sagirrarimeow // @description Adds draggable buttons to enable text selection and get cookies of the current page // @match *://*/* // @noframes // @exclude https://*.figma.com/* // @exclude https://*.google.com/* // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF60lEQVR4nO1ba2xTZRh+uHghSgQTCCaIQrwEFBSFAcK2wgQGA+IP9Y/+MUSCKAqJ6B9vifww2K5jOAgEnHTndDAJgyjC2rXjov4QBY1R6G5sYzIY0yUCAR3bY77Tll7OaXs6e9oz6JM8abacfec8z/d+7/t+3+mALLLIIossssgiiyyMAYlBdGIqZczhhxiMWwV0PTONbouDB6Z2UgYVSpBws4MHZ1hYW/At64rIw0tI7wKGGdDDKgxJOIYTRZTRThlnKWERBgJYM2U0PQXVrCvqU4QH6V0YMkBwK25LOJYQHjKtDWYHa2YvpbewK0J4kDWzIg2oxP03lQF053/EuqJeReyPb5Gn7OSx50MG7L0v0gAZKxKOKWFRIPzb6EQhzAq6LZv9QpeSTeVk33UqOO/xiz8wOVq8YDO3YzgGOlhrKVZEHllGdtQyAp3HyH3jtMQHuQsDGXTlr7wx851HI8V3/0zufzCeeLGu++jAXRiIYO3Mp+hdfFUx4Oy+SPFte8nK2+OL9xvgEw1SxLgSHqCMWsq4TBlu7sQ4mA2syx9Kz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xO8tAPs2ho71KPY02jHGpgFlJFDGS2JRF/YosyaHoHx2NFSggKYDdyO4ZRQquzPo8T3OGI0LknwtA29jTY4Wjcn90ot7aATj1FCdXiVOLvp/wlvsMHVWIxpGEigAw9RwoZrX6C1P8LrrTjXYEdZyxZMwkBHWylyGkvwToMNX9bb8JPPik7RvATEXvFZcd5nw4l6G3aL65psyDHdG6IsssgiHsQuTLytGQUoX4YWZ/WTAUwHMAdALoC5AOYBmA9gIYDFAJYEPhcGfj8vcF1u4O+mB8Z5ODDuqMB9Mv6PF4MBjAEwBUA+gKKAmHRR3C8vcP8x6TZkJIBn0yw4EUVnOCKdBhTcygZEL4G8DC6ByZlYAtBAdBIUSSs6CYqzej1JUFynlQTF12tTngT/A2q2kGcRt7PiAAAAAElFTkSuQmCC // @grant GM.cookie // @run-at document-idle // @connect * // ==/UserScript== (function () { 'use strict'; let enableCopyButton; let cookieButton; let cookieCleanButton; let isClicked = false; function enableTextSelection(e) { e.stopPropagation(); e.stopImmediatePropagation && e.stopImmediatePropagation(); applyTextSelection(); const events = ['copy', 'cut', 'contextmenu', 'selectstart', 'mousedown', 'mouseup', 'mousemove', 'keydown', 'keypress', 'keyup']; events.forEach(event => { document.documentElement.addEventListener(event, stopPropagation, {capture: true}); }); alert('Text selection enabled!'); isClicked = true; enableCopyButton.innerText = '🔓'; enableCopyButton.removeEventListener('click', enableTextSelection); } function applyTextSelection() { document.querySelectorAll('*').forEach(function (element) { if (window.getComputedStyle(element, null).getPropertyValue('user-select') === 'none') { element.style.setProperty('user-select', 'text', 'important'); } }); } async function getCookieString() { //const cookies = document.cookie; //const cookies = await cookieStore.getAll(); const cs = await GM.cookie.list({ url: window.location.host, partitionKey: {} }); console.log(cs); const cookieString = Object.values(cs).map(cookie => { return `${cookie.name}=${cookie.value}`; }).join('; '); prompt("Cookie Data:", cookieString); const name = prompt("Enter the localStorage name you'd like to access:", "access_token"); const localStorageItem = localStorage.getItem(name); prompt("localStorageItem:", localStorageItem); } function cleanWebsite() { const hostname = document.location.hostname; // Clear cookies document.cookie.split(';').forEach(cookie => { const [name, , domain] = cookie.trim().split(/=| |\./); //if (domain === document.location.hostname) { document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/; domain=${domain};`; //} }); localStorage.clear(); alert('First-party cookies, domain localStorage cleared!'); location.reload(); } function stopPropagation(event) { event.stopPropagation(); event.stopImmediatePropagation && event.stopImmediatePropagation(); } function findMaxZindex() { const zIndexes = []; document .querySelectorAll("*") .forEach(el => { const zIndex = parseInt(window.getComputedStyle(el).zIndex, 10); if (!isNaN(zIndex)) { zIndexes.push(zIndex); } }); return Math.max.apply(1, zIndexes); } function makeDraggable(button) { let isDragging = false; let startX, startY, startLeft, startTop; function onMousedown(e) { isDragging = true; startX = e.clientX; startY = e.clientY; startLeft = button.offsetLeft; startTop = button.offsetTop; document.addEventListener('mousemove', onMousemove); document.addEventListener('mouseup', onMouseup); } function onMousemove(e) { if (isDragging) { const dx = e.clientX - startLeft; const dy = e.clientY - startTop; moveButtonBy(dx, dy); } } function moveButtonBy(dx, dy) { button.style.transform = `translate(${dx}px, ${dy}px)`; } function onMouseup(e) { isDragging = false; startX = e.clientX; startY = e.clientY; startLeft = button.offsetLeft; startTop = button.offsetTop; document.removeEventListener('mousemove', onMousemove); document.removeEventListener('mouseup', onMouseup); } button.addEventListener('mousedown', onMousedown); } /////// const hoverStyle = { right: 0, }; const enableCopyStyle = { position: 'fixed', top: '80%', right: '-0.5rem', transform: 'translateY(-50%)', zIndex: findMaxZindex() + 1, transition: 'right 0.3s ease-in-out', } const cookieStyle = { position: 'fixed', top: '85%', right: '-0.5rem', transform: 'translateY(-50%)', zIndex: findMaxZindex() + 1, transition: 'right 0.3s ease-in-out', } const cleanWebsiteDataStyle = { position: 'fixed', top: '90%', right: '-0.5rem', transform: 'translateY(-50%)', zIndex: findMaxZindex() + 1, transition: 'right 0.3s ease-in-out', } function addButton() { const enableCopyButton = document.createElement('button'); enableCopyButton.classList.add('enable-copy-button'); Object.assign(enableCopyButton.style, enableCopyStyle); enableCopyButton.innerText = '🔓'; enableCopyButton.addEventListener('click', enableTextSelection); enableCopyButton.addEventListener('mouseenter', () => Object.assign(enableCopyButton.style, hoverStyle)); enableCopyButton.addEventListener('mouseleave', () => Object.assign(enableCopyButton.style, enableCopyStyle)); const cookieButton = document.createElement('button'); cookieButton.classList.add('cookie-button'); Object.assign(cookieButton.style, cookieStyle); cookieButton.innerText = '🍪'; cookieButton.addEventListener('click', getCookieString); cookieButton.addEventListener('mouseenter', () => Object.assign(cookieButton.style, hoverStyle)); cookieButton.addEventListener('mouseleave', () => Object.assign(cookieButton.style, cookieStyle)); const cleanWebsiteData = document.createElement('button'); cleanWebsiteData.classList.add('cookie-button'); Object.assign(cleanWebsiteData.style, cleanWebsiteDataStyle); cleanWebsiteData.innerText = '🧹'; cleanWebsiteData.addEventListener('click', cleanWebsite); cleanWebsiteData.addEventListener('mouseenter', () => Object.assign(cleanWebsiteData.style, hoverStyle)); cleanWebsiteData.addEventListener('mouseleave', () => Object.assign(cleanWebsiteData.style, cleanWebsiteDataStyle)); document.body.append(enableCopyButton, cookieButton, cleanWebsiteData); makeDraggable(enableCopyButton); makeDraggable(cookieButton); } addButton(); })();