您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a button to SimilarWeb competitor list items to open the competitor's url in a new tab/window when clicked.
// ==UserScript== // @name SimilarWeb Add Open Page Button // @namespace Lalala // @author Lalala // @version 0.1 // @description Adds a button to SimilarWeb competitor list items to open the competitor's url in a new tab/window when clicked. // @match https://www.similarweb.com/*/website/* // @run-at document-idle // @grant none // @license MIT // ==/UserScript== window.onload = function() { 'use strict'; const items = document.querySelectorAll('.wa-competitors__list-item'); const createButton = (url) => { const button = document.createElement('a'); button.classList.add('swui-button', 'swui-button--solid', 'swui-button--negative', 'wa-competitors__list-item-compare'); button.setAttribute('data-test', 'button'); button.href = `https://${url}`; button.target = '_blank'; const span = document.createElement('span'); span.textContent = '打開網站'; const websiteSpan = document.createElement('span'); websiteSpan.classList.add('wa-competitors__list-item-website'); websiteSpan.textContent = `至 ${url}`; span.appendChild(websiteSpan); button.appendChild(span); return button; }; const addButton = (wrapper, button) => { wrapper.parentNode.insertBefore(button, wrapper); }; const addButtons = () => { for (const item of items) { const analyzeLink = item.querySelector('.wa-competitors__list-item-title'); const analyzeWrapper = item.querySelector('.wa-competitors__list-item-analyze-text'); if (analyzeLink && analyzeWrapper) { const button = createButton(analyzeLink.innerHTML); addButton(analyzeWrapper, button); } } }; addButtons(); };