您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Make a span clickable by extracting an href and wrapping it in an anchor tag
// ==UserScript== // @name Shoptet - upravit produkt jako link // @namespace https://greasyfork.org/en/scripts/529581-shoptet-upravit-produkt-jako-link // @version 1.01 // @description Make a span clickable by extracting an href and wrapping it in an anchor tag // @author Michal // @include * // @grant none // @require https://code.jquery.com/jquery-3.6.0.min.js // ==/UserScript== /* globals $ */ (function() { 'use strict'; // Wait until the page fully loads function modifySpan() { let href = $("#bar-menu").children().eq(2) // Get the third child .find("ul") // Find the <ul> inside it .children().eq(1) // Get the second child of <ul> .find("a") // Find the <a> tag inside it .attr("href"); // Get the href attribute console.log("Extracted href:", href); // Output the href value if (href) { let span = $("#bar-menu").children().eq(2).find("span"); // Find the <span> inside it if (span.length > 0) { // Wrap the span inside an <a> tag span.wrap(`<a href="${href}" target="_blank"></a>`); console.log("Span successfully wrapped inside <a>"); } } } // Ensure jQuery is available (most sites have it, but if not, inject it) function ensureJQuery(callback) { if (window.jQuery) { callback(); } else { let script = document.createElement("script"); script.src = "https://code.jquery.com/jquery-3.6.0.min.js"; script.onload = callback; document.head.appendChild(script); } } // Run script when the page is fully loaded ensureJQuery(() => { $(document).ready(function() { setTimeout(modifySpan, 2000); // Delay execution to ensure elements are loaded }); }); })();