TA的每日心情 | 开心 2024-7-27 20:27 |
---|
签到天数: 1 天 [LV.1]初来乍到
荣誉开发者
- 积分
- 11
|
发表于
2024-5-4 15:48:43
|
显示全部楼层
// ==UserScript==
// @name AutoFill Keywords Script
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Automatically 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 [keyword, content] 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[type="text"], 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);
})();
這個應該可以達到你要的要求~自己測試 任何網頁都通用~~~置換你設定的內容即可 |
|