How to remove CSS Class with Tampermonkey?

谁说我不能喝 提交于 2019-12-02 07:26:27

That looks to be an AJAX-driven web page, so you need to use AJAX-aware techniques to deal with it. EG waitForKeyElements, or MutationObserver, or similar.

Here's a complete script that should work:

// ==UserScript==
// @name     _Remove a select class from nodes
// @match    *://app.hubspot.com/reports-dashboard/*
// @match    *://app.hubspot.com/sales-notifications-embedded/*
// @require  http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @require  https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant    GM_addStyle
// ==/UserScript==
//- The @grant directive is needed to restore the proper sandbox.
console.log ("Do you see this?");

waitForKeyElements (".disable-stream", removeDSclass);

function removeDSclass (jNode) {
    console.log ("Cleaned node: ", jNode);
    jNode.removeClass ("disable-stream");
}

Note that there are two @match statements because the nodes, that the OP cared about, turned out to be in an iframe.

var divs =document.getElementsByClassName("stream-notifications");

divs=Array.from(divs);

divs.forEach(function(div){
  div.classList.remove('disable-stream');
 });

Use something like this using jQuery

$(".disable-stream div").removeClass("disable-stream");

Plunker demo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!