Monitor click events on bookmarks (Google Apps Script) - events

Is there a way to monitor click events on bookmarks in google documents with google apps script? I want to get bookmark id when someone selects a bookmark and than run some more code which needs that bookmark id to get processed.

With Brian Bennett's help I managed to solve this issue with Web Apps. There is a little bit more code to write but it works.
Write a doGet function:
doGet function is called when a user visits your Web App. With doGet function I opened a document with ID given through get parameters and displayed it as html. To get a html of the document I used this function.
Find and display bookmarks:
You can find bookmarks in the html of the document as html tag with id of the bookmark. I changed the css of all this tags so I could see them (change background, height, width or something like that).
listen to click events on bookmarks with jquery or just javascript:
Listen to click events on those tags (bookmakrs) with jquery or javascript. If you use jquery, you need to import a jquery library. When click event happens get the id of the bookmark from the id attribute of the tag.
Use that bookmark id as you wish...

Related

Can bookmarket modify original page?

I have a bookmarklet that opens a dialog (in reality an iframe) and extracts some information. When the dialog is dismissed I want to put that information into edit text fields on the original page in the browser (like the way LastPass will automatically fill-in login forms on a page).
Is this possible? I'm thinking that same-origin-policy will prevent this, but maybe there is a way (without installing extensions such as greasemonkey, etc).
Edit: to be more precise: the bookmarklet appends a DIV to the original page; that DIV contains an IFRAME that loads my page; this page fetches some information; once this information is fetched within the IFRAME I want to remove the DIV and (somehow) put that information into the original page.
The issue I face is communicating the information in the IFRAME back to the original page.
What you are looking for are the functions addEventListener and postMessage.
Relevant links:
http://caniuse.com/#feat=x-doc-messaging
How do you use window.postMessage across domains?

Firefox addon - is it possible to capture text/html from the webpage?

I have never wrote a firefox addon so I am wondering if this can be done. Is it possible to continually scan a webpage for certain text, and then if that text appears, capture it and save it to a file?
For example
Say a user is on amazon and adds a few items to their shopping cart.
They click checkout and fill in their details and click submit order.
When the order is processed the user is shown the text 'Order complete' and given a receipt of their purchase.
In this example I would like to keep scanning the webpage until 'Order complete' appears. Then I want to capture the html of the receipt and save it to a file.
Is this possible with a firefox addon?
From my experience as a Firefox user, this is definitely possible. As a matter of fact there are add-ons that do far more than that.
For example, Greasemonkey can actually act as a filter and change the content of a viewed webpage as specified by a user script. Zotero and AlertBox are able to selectively watch specific HTML elements for interesting information and act upon it.
It is also quite possible that there is an existing add-on that either does what you need already, or can be used as a basis for a custom add-on of your own - what you are asking for is not all that unusual...
You probably want to create your add-on with the Add-on SDK. You can then use the page-mod package to attach a content script to Amazon pages. The content script should check whether it got loaded into an order confirmation page - and send the HTML code of that page (probably document.body.innerHTML) back to the extension.
The extension then needs to write the data to a file. You need to use internal API for that, something like this:
var file = require("file");
var writer = file.open("c:\\foo\\bar.html", "w");
writer.writeAsync(data);
If you want the user to choose the file name, you can do this using chrome authority and nsIFilePicker component.

Firefox add-on to display iFrame

I'm trying to create firefox addon which will add an icon near the address bar, and when the user will click it, it will show an iframe which I'll set.
Something similiar to chrome extension, as like this:
http://code.google.com/chrome/extensions/images/hello-world.png
Thanks
Here is an overlaying method.
Article : Creating toolbar button # MDC
XUL of popup box can refer to notification-popup and identity-popup(suggested) at chrome://browser/content/browser.xul
And iframe is avaiable in XUL.
<panel id="sth-popup" type="arrow" hidden="true" noautofocus="true" onpopupshown="(initial action)" level="top">
<iframe id="sth-body" src="chrome://(extenstion name)/(sth html)" flex="1"/>
</panel>
For the listeners (onclick, onkeypress) of toolbar button , please refers to gIdentityHandler . handleIdentityButtonEventat chrome://browser/content/browser.js
If your addon is a bootstrapped extension, please refers to Playing with windows in restartless (bootstrapped) extensions at Oxymoronical.
Javascript DOM control technique is required.
Refers to the XUL example and create the elements simply by document.createElement method or even bydocument.createElementNS(XULNS, "(tag name)") method, whereconst XULNS = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'; had been written.
Feel free to ask more and to be one of our registered users. :-)
Your problem is with the creation of the iframe? or with creating the iframe content? (for instance u can't set a src attribute to a file which is not the domain of the page where u want to display the iframe)

Event handler for location.hash changing?

I have a Flash document viewer embedded in my page, where the user can view the preview version of the document, and then purchase the full version if they like. Is it possible to have a hyperlink in the document itself "BUY NOW" which would command the browser to do something on the current page without having to refresh?
I'm imagining something like:
www.example.com/currentpage.php#buy
...as a link in the embedded document, which would in theory scroll to a position in the parent web page. Are there any mechanisms, maybe event handlers where I can run some js upon being directed to the "#buy" anchor?
EDIT: I just discovered Javascript has a
window.location.hash
object that I can check, but I don't want to poll for it, the question remains if there are any mechanisms or events to detect it changing?

How to get back button to work with anchors (#) and iframes

I am working on a site where the main part of it is driven by an ajax style navigation system using anchors in the url to define the application state.
On top of this I now need to support IFrames that are loaded on top of this application. The problem I'm having is that the back button breaks if I make use of fragments.
I've created a very simple sample, that isn't using any of the ajax libraries. All it has is a link that adds an anchor to the url and an iframe, with some normal links in it.
If I click then anchor link first, then I click the link in the iframe, I would expect the first back click to take back to the original iframe page and the second click to remove the anchor from the url.
I'm aware of all the various solutions out there (YUI, reallysimplehistory, jquery plugin) and they all work great, but they don't cater for iframes.
I'm also aware that I could add some JS to the framed pages and possibly route all navigation through the parent page, but I'm hoping that isn't necessary.
So the question is, can anyone explain what is going on inside the history object in this sample? Secondly is there anything I can do from the parent iframe to coax the history object to pick up these navigation entries?
Note: I'm only enquiring about FF/Safari/Chrome in this sample. IE needs to looked at separately.
Refer to
JavaScript .hashchange performance. Can it bring any slowdown?
and
How does Gmail handle back/forward in rich JavaScript?

Resources