Stella inattivaStella inattivaStella inattivaStella inattivaStella inattiva
 

Recently I found a solution to run a javascript to temporary apply changes on a web site.

I had 2 cases where I changed some stuff in 3rd party webpage. Of course it's a temporary change until the page is reloaded.

In one case I need to remove the class "hidden-print" because the print invoice do not print some info. I need that but the supplier never fix it.

 

The following javascript is runnable from console and remove the class "hidden-print" from each elementb. You can run it from Browser console but it's not confortable like a bookmark.

// Remove the class hidden-print from the current webpage
// This works only in the browser console of the inspector (F12 for Chrome and others)
document.querySelector('.hidden-print').classList.remove('hidden-print');

 

We will put our javascrip inside the following code

 

Javascript:(function(){
    // Your code here
})();

 

 

Final code to put as url in our Bookmark

// use me as URL as bookmark in the browser
javascript:(function(){
    const aElements = document.querySelectorAll('.hidden-print');
    aElements.forEach(e => {
    e.classList.remove('hidden-print');
});
})();

 

SUGGEST

If your script has a lot of lines or it has multi-lines you should consider to minified-compress your code.In the references section there is a good link.

Here the same script minified. 

javascript:!function(){let e=document.querySelectorAll(".hidden-print");e.forEach(e=>{e.classList.remove("hidden-print")})}();

 

ANOTHER EXAMPLE

This example will show you how to change user-select from none to initial.

User-Select=none means you cannot select the text. It's a simple way to protect the text and not allow to copy it.

You can find a page with user-select disabled here. Test the simple javascript to enable the text selection on this page.

 

Javascript:(function(){document.querySelectorAll("body")[0].style.userSelect="initial";})();

 

 

 

 

 

 

 

 

DISQUS - Leave your comments here