admin管理员组文章数量:1318573
I am very new to CSS and javascript, so take it easy on me.
I am trying to remove the class disable-stream
from each of the div elements under the div class="stream-notifications". (See image, below)
I have tried the following in Tampermonkey, but it doesn't seem to work:
(function() {
'use strict';
disable-stream.classList.remove("disable-stream");})();
I am very new to CSS and javascript, so take it easy on me.
I am trying to remove the class disable-stream
from each of the div elements under the div class="stream-notifications". (See image, below)
I have tried the following in Tampermonkey, but it doesn't seem to work:
(function() {
'use strict';
disable-stream.classList.remove("disable-stream");})();
Share
Improve this question
edited Nov 28, 2017 at 20:44
Brock Adams
93.6k23 gold badges241 silver badges305 bronze badges
asked Nov 28, 2017 at 19:57
inputchipinputchip
1073 silver badges13 bronze badges
2
- 1 Avoid images of texts - it is better to read if you paste the text properly formatted here. – Leonardo Alves Machado Commented Nov 28, 2017 at 20:17
- Surprisingly, I couldn't find a good dupe target for this. Good question. – Brock Adams Commented Nov 28, 2017 at 20:42
3 Answers
Reset to default 5That 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 plete script that should work:
// ==UserScript==
// @name _Remove a select class from nodes
// @match *://app.hubspot./reports-dashboard/*
// @match *://app.hubspot./sales-notifications-embedded/*
// @require http://ajax.googleapis./ajax/libs/jquery/2.1.0/jquery.min.js
// @require https://gist.github./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
本文标签: javascriptHow to remove CSS Class with TampermonkeyStack Overflow
版权声明:本文标题:javascript - How to remove CSS Class with Tampermonkey? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742048491a2417933.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论