How can I block based on URL (from address bar) in a safari extension
Posted
by
PerilousApricot
on Stack Overflow
See other posts from Stack Overflow
or by PerilousApricot
Published on 2011-06-21T20:07:52Z
Indexed on
2011/06/22
0:23 UTC
Read the original article
Hit count: 394
safari
|safari-extension
I'm trying to write an extension that will block access to (configurable) list of URLs if they are accessed more than N times per hour. From what I understand, I need to have a start script pass a "should I load this" message to a global HTML page (who can access the settings object to get the list of URLs), who will give a thumbs up/thumbs down message back to the start script to deny/allow loading.
That works out fine for me, but when I use the usual beforeLoad/canLoad handlers, I get messages for all the sub-items that need to be loaded (images/etc..), which screws up the #accesses/hour limit I'm trying to make.
Is there a way to synchronously pass messages back and forth between the two sandboxes so I can tell the global HTML page, "this is the URL in the window bar and the timestamp for when this request came in", so I can limit duplicate requests?
Thanks!
© Stack Overflow or respective owner