You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在常访问的多子URL网站自动添加指向localhost的功能按钮?

Totally Feasible! Here's Your Step-by-Step Solution

This is exactly the kind of problem browser user scripts were made for—no need to modify the target website’s code or reconfigure your XAMPP setup. Let’s break down the simplest way to implement this with Tampermonkey (the most popular user script manager, supported on Chrome, Firefox, Edge, and more):

Step 1: Install Tampermonkey

  • Head to your browser’s extension store (Chrome Web Store, Firefox Add-ons, etc.), search for "Tampermonkey", and install it. You’ll see a little monkey icon pop up in your toolbar once it’s done.

Step 2: Write Your Custom User Script

Click the Tampermonkey icon, select "Create a new script", and replace the default template with this code (tweak the parts marked with comments to match your setup):

// ==UserScript==
// @name         Local Analysis Site Jump Button
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Adds a one-click button to jump to your localhost analysis site on your frequent website
// @author       You
// @match        *://your-frequent-site.com/*  // Replace this with your target website's domain (e.g., *://example.com/*)
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Create the jump button
    const jumpButton = document.createElement('button');
    jumpButton.textContent = 'Open Local Analysis';
    // Style the button to stand out (adjust these styles to match your preference)
    jumpButton.style.position = 'fixed';
    jumpButton.style.top = '20px';
    jumpButton.style.right = '20px';
    jumpButton.style.padding = '10px 18px';
    jumpButton.style.background = '#2563eb';
    jumpButton.style.color = 'white';
    jumpButton.style.border = 'none';
    jumpButton.style.borderRadius = '6px';
    jumpButton.style.cursor = 'pointer';
    jumpButton.style.zIndex = '9999'; // Ensures the button stays on top of other page content

    // Add click event to open your localhost site
    jumpButton.addEventListener('click', () => {
        // Replace this URL with your actual XAMPP localhost address
        window.open('http://localhost:8080/your-analysis-page', '_blank');
        // Use window.location.href = '...' instead if you want to open it in the same tab
    });

    // Attach the button to the page
    document.body.appendChild(jumpButton);
})();

Step 3: Configure and Enable the Script

  • Update the @match line to target your frequent website (use * as a wildcard, e.g., *://www.reddit.com/* matches all Reddit subpages).
  • Replace the localhost URL in the window.open line with your actual XAMPP site address (like http://localhost/my-analysis-tool if you’re using the default port 80).
  • Save the script, then refresh your target website—you’ll see the button floating in the top-right corner, ready to click!

Alternative Options (If Tampermonkey Isn’t an Option)

If you can’t use Tampermonkey for some reason, here are two backups:

  • Bookmarklet: Turn the button logic into a bookmark you can click on when visiting the target site. Compress this code into a bookmark (just copy-paste it as the bookmark’s URL):
    javascript:(function(){const b=document.createElement('button');b.textContent='Open Local Analysis';b.style.cssText='position:fixed;top:20px;right:20px;padding:10px 18px;background:#2563eb;color:white;border:none;border-radius:6px;cursor:pointer;z-index:9999';b.onclick=()=>window.open('http://localhost:8080/','_blank');document.body.appendChild(b)})();
    
    When you’re on the target site, click this bookmark, and the button will appear instantly.
  • Minimal Browser Extension: For more control (though overkill for this use case), you can build a tiny browser extension with the same core logic. This requires packaging the code as an extension file, but it’s only necessary if you need to distribute this to multiple devices or have stricter browser policies.

内容的提问来源于stack exchange,提问作者user431806

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 08:11:23