Tuesday, June 16, 2020

Very handy one-line Javascript codes that you can run right from the browser's address bar


These Javascript snippet are friendly-user hacks, that can be executed directly from the browser's address bar. The execution of these one-line scripts has affects only on the website's loaded document.

Javascript scheme can be used in address bar of the browser to run script on the loaded document
Javascript scheme can be used in the address bar of the browser to run script on the loaded document


The advantage with this approach; is that it uses vanilla Javascript and doesn't require any plugin on the browser or needs the developer console. You just need to copy/past the code into the address bar, after the prefix "Javascript:" typed beforehand.

Important : Don't copy/past the code with the prefix "javascript:" at once, otherwise the browser will ignore the prefix when pasting in the address bar. 




Show masked password saved in login form  : 

It is not easy to remember the last time you typed your password in login form, specially if the browser has saved it for you. Just use this below snippet to have the chance to remember it again.
Use this code when the login page is fully loaded and password input is filled with asterisk or dots.
 

javascript:alert("Your Password is : "+document.querySelectorAll("input[type=password]")[0].value);


Quick export table to excel :

Web page can have interesting data represented in form of (html) tables, sometimes there is a need to process the data in Excel, separately from the web page's content.

The following snippets allow you to export a table to Excel. You just need to know the order in which the table is displayed on the page, for instance if the page has 4 tables and you want to extract the second table, you replace TABLE_INDEX with 1 (not 2 !)

.

javascript:window.open('data:application/vnd.ms-excel,' +  encodeURIComponent(document.getElementsByTagName('table')[TABLE_INDEX].innerText)); 









(The code snippet formatting was made with http://hilite.me/)

No comments:

Post a Comment

What do you think ?

Posts