Ruud14 / Page-Manipulator

Browser Extension that can automatically inject custom HTML, CSS or JavaScript into any web-page. This way you can customize any web-page to fit your needs. Currently available on Google Chrome and Microsoft Edge.
https://chrome.google.com/webstore/detail/page-manipulator/mdhellggnoabbnnchkeniomkpghbekko?hl=nl
90 stars 31 forks source link

Page Manipulator fails to inject JavaScript #28

Closed R-O-BTheRobot closed 1 year ago

R-O-BTheRobot commented 1 year ago

I'm using MS Edge Dev 109.0.1495.2. I use Page Manipulator's JS injections to remove blocked messages from chat.

Discord's blocked messages are all of class "groupStart-3M1gv1". I include this or the shortened version in my JS code, attached below.

function hideBlocked(){
    const blocked = document.querySelectorAll('[class^="groupStart"]'); // Find all "Blocked Messages"
    blocked.forEach(blokMsg => {
        if(blokMsg.style.display !== "none") blokMsg.style.display = "none"; // Hide the message if it's not already hidden.
    });
};
setInterval(hideBlocked, 100); // Repeat every half second. Recommended to keep at 500, but raise/ lower if you wish.

The JS injection is Active, has only "discord.com" in the Active Pages field and is Recursively matching websites.

Below, I attach a video of the observed behavior. I also try it with a CSS injection to show that functions properly.

https://user-images.githubusercontent.com/67348603/203663682-2740e151-178d-4e26-a7d8-6287c709735a.mp4

Ruud14 commented 1 year ago

Hi,

I would recommend putting some console.log statements in your code to debug what is going wrong: Is the queryselector not finding the right elements? does setting style.display not hide the elements? etc.

You can view the console.log messages in the browser console (f12 -> console).