Post date: Apr 5, 2015 3:26:16 PM
The easiest option to run arbitrary JavaScript on any site is to use the element inspector or the console but if that is not available, all is not lost....
Chrome lets you enter JavaScript code on the search bar ( you know the thingy on top where the url usually is)
the trick is to start the url with "javascript:"
The problem is.. almost every JavaScript snippet gives a return value and that will be used to produce a new page. So we need to stop it from returnin anything and that trick is a function
javascript:(function(){alert('hey')})()
is this hard to remember? yeah I think so
so I start with javascript:
then I make the boobs ()()
so I get: javascript:()()
put the function in the first BOOB (smirk)
function(){}
so you get: javascript:(function(){})()
now all you have to do is put your code into the curly brackets
alert('hey')
javascript:(function(){alert('hey')})()
A little explanation:
javascript:()()
The stuff between the first bracket is the function, the brackets make it into one single object, the sencond pair of brackets calls the function. So no return code and the page stays right were it is.
This is also the way to make #bookmarklets,
Now these are the things that will give you control back over websites that you visit.