javascript - 工作的tampermonkey脚本在网站上不起作用
问题描述
<div id="captchaWindow" style="display: none;> </div>
我有工作脚本来更改显示以阻止但它在网站上不起作用我不明白我做错了什么以及它们如何阻止我的脚本工作。(按 j 隐藏/显示)
// ==UserScript==
// @name captcha
// @namespace c
// @version 0.1
// @description try to take over the world!
// @author You
// @match *://*.agar.io/*
// @grant none
// ==/UserScript==
function myFunction() {
var x = document.getElementById("captchaWindow");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
document.addEventListener("keydown", function(){
if (event.which === 74)
{myFunction();}
});
我的最终目标是在验证码有效时“自动”隐藏验证码,并在验证码过期后再次显示......我还没有找到它是如何工作的(哪个元素说它是有效的)。
解决方案
您需要myFunction();
在代码的末尾。
推荐阅读
- python - 如何将sql语句转换为json
- hadoop - 重试连接服务器:hadoopmaster/IP:9000
- python - 通过crontab运行python脚本找不到导入
- tensorflow - TensorFlow Keras GCP ML 引擎模型服务
- html - 错误:“body”之后的无效 CSS:预期的选择器或 at-rule,在第 4 行是“{”
- sql - BigQuery 中的数据透视表
- ram - 我应该为我的笔记本电脑购买哪种 RAM 类型?
- macos - 如何在主目录中创建 .gdbinit (Mac OS)
- javascript - YouTube 分析:无法解析内容
- jsf - p:panel facet "options" with p:menu - 无法设置与默认 "ui-icon-gear" 不同的图标