简体   繁体   English

如何从 Greasemonkey 脚本中取消选中 HTML 页面上的所有“md-checkboxes”(不是真正的复选框)?

[英]How do I uncheck all “md-checkboxes” (NOT real checkboxes) on a HTML page from a Greasemonkey script?

After wasting countless sweaty hours, swearing and cursing the name of the only food store I can use and how they keep checking their user-hostile options every single pageload, no matter how many times I uncheck them, and no matter how many times I report this "bug" (it's deliberate), I am simply forced to ask you experts for help.在浪费了无数汗水之后,咒骂和诅咒我唯一可以使用的食品店的名字,以及他们如何在每次页面加载时不断检查他们的用户敌对选项,无论我取消选中多少次,无论我报告多少次这个“bug”(这是故意的),我只是被迫向你们专家寻求帮助。

The webpage doesn't use real HTML checkboxes, but instead something they call "md-checkboxes".该网页没有使用真正的 HTML 复选框,而是他们称之为“md-checkboxes”的东西。 It's an "AngularJS" thing.这是一个“AngularJS”的东西。 The AngularJS manual doesn't explain anything whatsoever, and neither does any of the numerous webpages (including Stack Overflow questions) I've been plowing through. AngularJS 手册没有解释任何内容,我一直在研究的众多网页(包括 Stack Overflow 问题)也没有任何解释。 None of the seemingly relevant code snippets do anything but dump various errors in the console.看似相关的代码片段除了在控制台中转储各种错误外,没有任何作用。

This is the overall structure I have:这是我的整体结构:

function turn_the_damn_things_off()
{
    var checkboxes = document.getElementsByTagName('md-checkbox');

    for (var i = 0; i < checkboxes.length; i++)
    {
        // I have tried countless things here, but nothing works. The checkboxes are never unchecked. I am, however, certain that the code here executes.
    }
}

setInterval(turn_the_damn_things_off, 500);

The reason I do this in an interval is that they seem to be re-checked not right away but after about a second after the page has been loaded.我在一段时间内这样做的原因是它们似乎不是立即重新检查,而是在页面加载后大约一秒钟后重新检查。

for (var i = 0; i < checkboxes.length; i++)
{
  let x = checkboxes[i];
  if(x.getAttribute("aria-checked") === "true")
    x.classList.toggle("md-checked");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM