What is the best way to modify a specific field in a form?
Specifically what I'd like to do is "alter" one of the fields in the Google Calendar field entry for my own purposes. Namely the location is almost always going to be one of four locations, but the way the Google Calendar is set up it doesn't track frequently entered information, and writing the full address every time (or keeping a notefile w/ the 4 addresses to C&P) is kind of annoy开发者_如何学Going.
Ideal I suppose would be an "extension" or script that would automagically detect that I'm filling out a Google Calendar event entry and change the location field to a drop with the four addresses I frequently use as well as an "other" option.
Another possibility might be some kind of bookmarklet (or set of 4) that fills the location field in.
I don't really know where to start or which method would be better (hell, there might well be a third option that is superior).
PS: If this would be easier/more efficiently done in Firefox or some other browser rather than Chrome that is fine as well.
I'd go with bookmarklets. Here's a potential URL for setting addresses given the current Google Calendar page (the id of the "Where" input is ":1u"):
javascript:document.getElementById(':1u').value='123 Some st.'; void(0);
I'd write bookmarks with URLs similar to the above for each of your 4 addresses and then put them into an easily accessible folder, and use them each time you want to populate that address.
UPDATE:
Since the ID changes, you can get it by the class name. However, if the class changes or the number of inputs before the Where field changes, you'll have to update your links:
javascript:document.getElementsByClassName('textinput')[1].value='123 Some st.'; void(0);
UPDATE 2:
Apparently Google doesn't consider the current value of the textbox when a Calendar item is saved. I fixed this by manually firing the 'change' event after the value of the textbox is updated. The following currently works in Firefox:
javascript:var a=document.getElementsByClassName('textinput')[1];a.value='123 Some st.';var e=document.createEvent("HTMLEvents");e.initEvent('change',true,true);a.dispatchEvent(e);void(0);
精彩评论