// ==UserScript== // @name TikTok Clickable Plox // @namespace tiktok-clickable-plox // @description Hace clicables con rueda del raton videos relacionados (miniatura y título) en TikTok Desktop y añade toggle para abrir en nueva pestaña al darles click normal. // @version 0.0.2 // @author Alplox // @match https://www.tiktok.com/* // @icon https://www.tiktok.com/favicon.ico // @grant GM_addStyle // @grant GM_getValue // @grant GM_setValue // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // @run-at document-end // @license MIT // @homepageURL https://github.com/Alplox/TikTok-Clickable-Plox // @supportURL https://github.com/Alplox/TikTok-Clickable-Plox/issues // @downloadURL https://raw.githubusercontent.com/Alplox/TikTok-Clickable-Plox/refs/heads/main/tiktok-clickable-plox.user.js // @updateURL https://raw.githubusercontent.com/Alplox/TikTok-Clickable-Plox/refs/heads/main/tiktok-clickable-plox.meta.js // ==/UserScript== (function () { 'use strict'; // --- CONFIGURACIÓN DEL ESTADO --- const RELATED_KEY = 'tiktok_open_related_new_tab'; const SHOW_FULL_URL_KEY = 'tiktok_show_full_url_in_bio'; // Establecido a 'false' para que esté DESACTIVADO por defecto // Si el valor guardado es 'false', se usa. Si no existe, se usa 'false' por defecto. let openRelatedInNewTab = GM_getValue(RELATED_KEY, false); let showFullUrl = GM_getValue(SHOW_FULL_URL_KEY, false); let menuRelatedId = null; let menuFullUrlId = null; // --- MENÚS --- function updateMenus() { if (typeof GM_unregisterMenuCommand === 'function') { if (menuRelatedId !== null) GM_unregisterMenuCommand(menuRelatedId); if (menuFullUrlId !== null) GM_unregisterMenuCommand(menuFullUrlId); } menuRelatedId = GM_registerMenuCommand( `${openRelatedInNewTab ? '✅ Activado' : '❌ Desactivado (por defecto)'} abrir relacionados en nueva pestaña`, () => { const wasActive = openRelatedInNewTab; // Guarda el estado actual openRelatedInNewTab = !openRelatedInNewTab; // 1. Guardar el nuevo estado GM_setValue(RELATED_KEY, openRelatedInNewTab); // 2. Aplicar/retirar estilo dinámico que hace clickables los enlaces setClickableStyle(openRelatedInNewTab); // 3. Si se DESACTIVA, eliminar handlers y forzar un re-scan para limpiar marcas/atributos if (wasActive && !openRelatedInNewTab) { // quitar handlers/flags y restaurar anchors detachHandlers(document); // re-scan para elementos hijos nuevos si fuera necesario scan(document); updateMenus(); return; } // 4. Si se ACTIVA, hacer un re-scan para añadir handlers a los elementos ya existentes updateMenus(); scan(document); } ); menuFullUrlId = GM_registerMenuCommand( `${showFullUrl ? '✅ Mostrando' : '❌ Ocultando (por defecto)'} URL completa en biografía`, () => { showFullUrl = !showFullUrl; GM_setValue(SHOW_FULL_URL_KEY, showFullUrl); applyFullUrlStyle(document); updateMenus(); } ); } // --- ESTILOS GENERALES --- // Reglas base (siempre aplicadas). NOTA: la regla que forcea "pointer-events:auto" para enlaces // se maneja dinámicamente en setClickableStyle() para poder desactivar sin recargar. GM_addStyle(` [data-e2e="user-post-item"], [data-e2e="video-item"], [data-e2e="video-card"], a[href*="/video/"], a[href*="/@"] { user-select: text !important; } .tiktok-overlay, .overlay, [data-e2e="video-overlay"] { pointer-events: none !important; } `); // Elemento