Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
386 views
in Technique[技术] by (71.8m points)

javascript - function as google chrome bookmark

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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";})();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...