Function as Google Chrome bookmark

JavascriptJqueryGoogle ChromeBookmarks

Javascript Problem Overview


Let me first say the problem I have: I need to fill in the same web page a lot of times, and the content that I need to fill in is for the biggest part the same, but is scattered all over the webpage.

The solution i was thinking of: I know there is a way to create some javascript function that you put behind a google bookmark so that when you are on the page, you just click that bookmark, and it will do some things.

I was wondering if anyone used (or created) something like this. If you can make this yourself, how do you start with it? And can you use jquery?

If it's possible to create this, I was also wondering if it would be possible to, when you click, show a pop-up to ask a few parameters, so that I don't need to fill in the same thing 3,4 times

Javascript Solutions


Solution 1 - Javascript

You can do this using a bookmarklet. A bookmarklet is a bookmark with a URI starting with the pseudo-protocol javascript: followed by URI-encoded JavaScript code. When you trigger the bookmark, browser will run the code in the context of the current page. So you'd go to that page, then use that bookmarklet to fill in your standard information, and there you go.

For example, here's a bookmarklet that, when run, will look for an element with the id someElement on the page and, if found, assign "some value" to its value property:

javascript:(function(){var d=document,e=d.getElementById("someElement");e.value="some value";})();

Solution 2 - Javascript

This bookmarklet creator will come in handy to squish your JavaScript into one line: http://mrcoles.com/bookmarklet/

Solution 3 - Javascript

Here is an example of one that lets you edit the webpage like a document.

javascript:document.body.contentEditable = 'true'; document.designMode='on'; void 0

Solution 4 - Javascript

javascript : { document.getElementById('PlateNo').value='0815';document.getElementById('AppRef').value='013007';document.getElementById('VehicleReg').value='MX53 YMD'; void(0) }

Solution 5 - Javascript

You can use prompts and alerts and confirm windows, and I created a game, kind of. It's not that clean though. Here's the javascript-code:

To the editor: there needs to be a "javascript:" at the start for it to work btw

javascript: 
var totalClicks = 0;
for (var i = 0; i < 1000000; i++){
    var message1 = prompt("Clicker Game!\nClicks: "+totalClicks,"remove this text to end the game");
    totalClicks++;
    if (message1 !== "remove this text to end the game"){
        i = Math.Infinity;
    }
}
alert("Thanks for playing my game!\nClicks: "+totalClicks)

Solution 6 - Javascript

For Mozilla use like as

javascript:function myFun(){
var d=document;
var e=d.getElementById("someElement");
var e.value="some value";
}myFun();

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBrentgView Question on Stackoverflow
Solution 1 - JavascriptT.J. CrowderView Answer on Stackoverflow
Solution 2 - JavascriptdiazdeteranView Answer on Stackoverflow
Solution 3 - JavascriptMatthias SView Answer on Stackoverflow
Solution 4 - JavascriptHari GillalaView Answer on Stackoverflow
Solution 5 - Javascriptgoldenfire64View Answer on Stackoverflow
Solution 6 - JavascriptUmanathView Answer on Stackoverflow