Google Search Syntax Helper

Show Google search syntax on Google homepage and search results page

目前为 2024-07-30 提交的版本,查看 最新版本

// ==UserScript==
// @name         Google Search Syntax Helper
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Show Google search syntax on Google homepage and search results page
// @author       hzn
// @match        https://www.google.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Google search syntax text
    const syntaxText = `
        <div id="syntax-helper" style="
            position: fixed;
            background: white;
            border: 1px solid #ccc;
            padding: 10px;
            z-index: 9999;
            width: 300px;
            box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
            top: 10px;
            right: 350px; /* Adjust this value to move the box left or right */
        ">
            <strong>Google 搜索语法:</strong><br>
            <ul style="padding-left: 20px;">
                <li><code>"关键词"</code> - 精确匹配关键词</li>
                <li><code>关键词1 OR 关键词2</code> - 匹配任一关键词</li>
                <li><code>-关键词</code> - 排除某个关键词</li>
                <li><code>site:example.com</code> - 只在指定网站搜索</li>
                <li><code>filetype:pdf</code> - 搜索特定文件类型</li>
                <li><code>related:example.com</code> - 查找相似网站</li>
                <li><code>define:词汇</code> - 查询词汇定义</li>
                <li><code>intitle:关键词</code> - 标题中包含关键词</li>
                <li><code>inurl:关键词</code> - URL中包含关键词</li>
            </ul>
        </div>
    `;

    // Append the syntax helper to the body
    document.body.insertAdjacentHTML('beforeend', syntaxText);
})();