Removing a CSS Class Using Tampermonkey: A Step-by-Step Guide

I'm completely new to CSS and javascript, so please bear with me.

My goal is to remove the class disable-stream from each of the div elements located under the div with the class "stream-notifications". Below is an image for reference:

Even though I attempted the following code in Tampermonkey, it doesn't seem to be effective:

(function() {
'use strict';
disable-stream.classList.remove("disable-stream");})();

https://i.stack.imgur.com/FNFGz.jpg

Answer №1

It appears that the web page is AJAX-driven, which means you will need to utilize AJAX-aware techniques to handle it effectively. For example, consider using waitForKeyElements, MutationObserver, or similar methods.

Below is a comprehensive script that should address this issue:

// ==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");
}

It's important to note the presence of two @match statements due to the nodes being located within an iframe.

Answer №2

let notificationDivs =document.getElementsByClassName("stream-notifications");

notificationDivs=Array.from(notificationDivs);

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Navigating CSV-derived JSON data in Flask and Javascript: Best Practices

My current goal is to read a CSV file on the backend using Python/Flask and then display its data as an HTML table with Javascript. I have simplified my task to just displaying JSON values passed from Python in the browser console, which will help me build ...

JavaScript may not display height as anticipated

Currently, I am experimenting with JavaScript in order to achieve a website section that is 100% the height of the screen minus the "nav" bar. Imagine it as having two visible components - the first one being large and the second one small at the bottom. ...

What steps can I take to expand this on a grander level?

I have a code snippet for a personality quiz, but I'm facing an issue with increasing its size. Here's the HTML code: <h3>1. What is your favorite color?</h3> <input type="radio" name="q1" value="A" /> A. Red. <input type="r ...

Modify the background hue of the checkbox to resemble a button when selected

Is there a way to create a checkbox that resembles a button in appearance? I have managed to achieve this, but I am facing an issue with changing the background color of the button when it is checked. Currently, the button turns light-grey when checked, bu ...

By increasing the background-color to 100%, the list item obstructs the background image of its parent div

In cases where an element is set to display:block, the background-color of that element typically extends to 100% of the width of its parent element. However, I am seeking a solution where the background-color only reaches the edge of the text, allowing th ...

Vue.js - Implementing multiple values (array) for a component through a property

I am currently working with vue.js components that receive their data from external sources. For example: <vue-button icon="fa-arrow-right" text="mytext"></vue-button> Initially, this setup is effective. However, I encountered a challenge wh ...

Managing authentication for JSON API calls within the CakePHP REST plugin

I have been working on developing an API for my CakePHP application using the REST plugin available at: https://github.com/kvz/cakephp-rest-plugin The motivation behind utilizing this plugin is to facilitate authentication for API calls on protected metho ...

Postman seems to be functioning correctly while AXIOS is encountering issues

I've encountered a strange issue with my MERN app. When I use Postman to send a PUT request to my API, it successfully updates both the API and MongoDB. However, when performing the same action on the front-end, the API does not update even though the ...

Menu only appears with a double click on the label button

Currently, I'm facing an issue where I have to click the label "button" (hamburger menu) twice in order to show the menu for the second time. My belief is that there might be a conflict between CSS and jQuery causing this behavior. The desired funct ...

When downloading files in Chrome or Safari, the $ajax call is in a pending state, whereas in IE or Firefox,

Measuring the time it takes to download a 1MB file using AJAX calls. Below is the code snippet: var start = new Date(); $(document).ready(function() { $.ajax ({ url: 'https://www.example.com/dummyFile1024', crossDomain: t ...

Stop images from being stored in the database instead of text characters

Using a proxy, I attempt to parse some HTML. One of the elements is retrieved using jQuery: var site = 'http://www.kartabu.com/pl/index.php?filter=random' var url = 'http://localhost/taboo.blue-world.pl/admin/proxy.php?url=' + encodeUR ...

Using Vue to implement a "v-model" on a custom component that incorporates the ace-editor

Snippet CustomEditor.vue: <template> <div class="custom-container"> <div class="custom-editor" ref="editor"></div> </div> </template> <script> import ace from 'ace-builds' import 'ace- ...

Rearrange information when the textarea is adjusted in size

One issue I am facing is that when I resize the textarea in my form, the content below the textarea does not move along with it. How can I ensure that the content moves accordingly when resizing the textarea? <form name="contactform" method="post" ...

Is there a way to prevent inheriting width properties? Or perhaps how can one revert back to the original width value

After installing the Thank you plugin, I noticed that the button on my test site appears to be strange. Upon further investigation, I discovered that it is inheriting #commentform textarea { width: 45%; } from my theme. While removing the width in the CSS ...

Unable to view images on Wordpress theme

I am currently facing an issue where some images in my asset folder are not displaying properly when I convert my HTML/CSS/JS template to Wordpress. The main problem is with the image that should show up when you first visit the website. Below is the CSS c ...

Display information from a MySQL database in a tabular format using PHP

I am currently learning PHP and attempting to retrieve data from a database to display it in an HTML table. However, I am facing an issue where the total number of records returned is 13 but only 12 records are being displayed in the table (it seems to be ...

Cover the entire page with a solid background color

Is there a way to extend the green color from top to bottom on the page? Also, how can I move the CRUD section to the left? I'm having trouble filling the entire page with the content. Below is my code written in VueJS: <template> < ...

What is the reason behind the absence of compile time errors when using 'string' functions on an 'any' field type variable in TypeScript?

Looking at the following typescript code snippet: let a; a = "number"; let t = a.endsWith('r'); console.log(t); It is worth noting that since variable 'a' is not declared with a specific type, the compiler infers it as ...

Steps to dynamically change the select options using Jquery after successfully receiving data through Ajax

Upon clicking the button, I see console output correctly; however, my options are not updating. I am a beginner in Ajax, Jquery, and Django and have spent over a week trying to resolve these issues with no success. Please assist me. This is my Django code ...

Typescript raises an issue regarding a React component's optional prop potentially being undefined

I have a basic React component that looks like this: interface ComponentProperties { onClick?: () => void; } const CustomComponent = (properties: ComponentProperties) => { if (!properties.onClick) { return <></>; } ...