快捷导航栏

添加常用网站导航

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         快捷导航栏
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  添加常用网站导航
// @author       YourName
// @match        https://*/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    
    // 创建导航栏
    const nav = document.createElement('div');
    nav.style.cssText = `
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: #333;
        padding: 10px;
        z-index: 9999;
    `;
    
    // 添加链接
    const links = [
        { name: '百度', url: 'https://www.baidu.com' },
        { name: '知乎', url: 'https://www.zhihu.com' },
        { name: 'GitHub', url: 'https://github.com' }
    ];
    
    links.forEach(link => {
        const a = document.createElement('a');
        a.href = link.url;
        a.textContent = link.name;
        a.style.cssText = `
            color: white;
            margin: 0 10px;
            text-decoration: none;
        `;
        nav.appendChild(a);
    });
    
    document.body.prepend(nav);
    // 为了不遮挡内容,给body添加上边距
    document.body.style.marginTop = '40px';
})();