Ant*_*nko 3 google-chrome google-chrome-extensions
通常是否可以让 Chrome 不自动关注任何字段,例如,在页面加载后?
使用键盘上的键的扩展不能很好地与自动对焦和键入而不是执行命令一起使用。
我刚刚为你写了脚本:
// ==UserScript==
// @name Disable auto-focussing
// @author ComFreek <comfreek at the following domain 'outlook' with the TLD 'com'>
// @description Disable auto-focussing
// @include *
// @version 1.0
// ==/UserScript==
var maxTime = 3000;
var timeoutInterval = 5;
var usedTime = 0;
var isManualFocus = false;
function check() {
if (!isManualFocus && document.activeElement.tagName.toLowerCase() == "input") {
console.log("BLURRED");
document.activeElement.blur();
}
usedTime += timeoutInterval;
if (usedTime < maxTime) {
window.setTimeout(check, timeoutInterval);
}
}
check();
document.body.addEventListener("click", function (evt) {
if (evt.target.tagName == "INPUT") {
console.log("MANUAL CLICK");
isManualFocus = true;
}
});
document.body.addEventListener("keydown", function (evt) {
isManualFocus = true;
});
Run Code Online (Sandbox Code Playgroud)
警告如果用户在脚本仍在运行时立即开始输入,脚本将干扰用户。
这是固定的。
将脚本另存为XX.user.js
(XX 可以是任何字符串,但.user.js
在这里很重要!)
在 Chrome 中打开扩展程序页面(URIchrome://extensions/
从 Chrome v31 开始)
将脚本从文件资源管理器中拖放到扩展页面上。
确认安装
根据下面的 OP 评论,我的脚本应该与 TamperMonkey 一起使用。请查阅 TamperMonkey 的手册以获取有关如何安装我的脚本的更多信息。
归档时间: |
|
查看次数: |
7852 次 |
最近记录: |