scgagg2012 发表于 2024-4-23 10:46:23

求一个自动填充的插件或者脚本

能在用户打开的任何有填充内容要求的网页自动识别用户设定的关键字,然后输入提前设定的内容。例如抓取到关键字“我对事件的意见或看法”自动输入“非常满意”,抓取到百度一下,自动在框里输入“五年计划的实施”,

李恒道 发表于 2024-4-23 12:31:31

小众的基本只能靠自己开发了

s0919756 发表于 2024-5-4 15:48:43

// ==UserScript==
// @name         AutoFill Keywords Script
// @namespace    http://tampermonkey.net/
// @version      1.0
// @descriptionAutomatically fill in predefined content based on keywords detected on the page.
// @author       You
// @match      *://*/*
// @grant      none
// ==/UserScript==

(function() {
    'use strict';

    // Define your keywords and the corresponding content to fill
    const keywords = {
      "我对事件的意见或看法": "非常满意",
      "百度一下": "五年计划的实施"
    };

    // Function to detect keywords and autofill content
    function autoFillContent() {
      // Iterate over each keyword/content pair
      for (const of Object.entries(keywords)) {
            // Check if the keyword exists on the page
            if (document.body.innerText.includes(keyword)) {
                // Find the input field or area to fill
                const inputField = document.querySelector('input, textarea');
                if (inputField) {
                  // Fill in the predefined content
                  inputField.value = content;
                  break; // Stop after the first match to prevent overwriting
                }
            }
      }
    }

    // Run the autofill function when the page loads
    window.addEventListener('DOMContentLoaded', autoFillContent);
})();
這個應該可以達到你要的要求~自己測試 任何網頁都通用~~~置換你設定的內容即可
页: [1]
查看完整版本: 求一个自动填充的插件或者脚本