Url redirect question.

53 views
Skip to first unread message

Jaikumar G

unread,
May 10, 2012, 3:31:39 PM5/10/12
to chromium-...@chromium.org
Folks,

I start chrome from the command line with a default page loaded.

The default page is below.

<html>
<body onload="moduleDidLoad()">
<object id = "blah"/>
 <script>
    function moduleDidLoad() {
       id = document.getElement("blah");
       // Call some function on id
    }

    function urlLoad(url) {
    }
 </script>
</html>


Chrome also has an extension associated with it.
This extension has a java script file tagged as background.
It intercepts the url.
So when the user types www.google.com, I need to send the url
www.google.com to urlLoad function in page A and prevent the new page
associated with www.google.com from getting loaded. I need chrome to
continue to display Page A.

Page A is not defined in the manifest.json.

manifest.json looks something like this:

{
 "name": "URL mapper",
 "description": "URL mapper",
 "version": "1.0.0",
 "default_locale": "en",
 "permissions": [
  "contextMenus", "tabs", "webRequest",
  "webRequestBlocking", "http://*/*", "https://*/*"
 ],
 "background": {
  "scripts": ["url_script.js"]
 }
}


If the above is not possible since page A is not known to the
extension - I can make Page A part of the extension.

Everything Page A, extension is under my control.

Any pointers on how I can go about doing this ?

Devin

unread,
May 14, 2012, 10:46:58 PM5/14/12
to Chromium-extensions
1st - I would put your moduleDidLoad() function definition -above-
where you use it on the body tag.

I modify the experience of Google in my extension - but it looks like
you want to -intercept- it.

I would recommend using the webRequest's onBeforeRequest event to
redirect to another page of yours..

You could also present page A via a modification technique instead of
interception - simply setup a content script to be injected to all
www.google.com pages you want to intercept, be sure to inject on
document_start, and inject css that hides the page body, and insert
your page.

On May 10, 12:31 pm, Jaikumar G <jaieni...@gmail.com> wrote:
> Folks,
>
> I start chrome from the command line with a default page loaded.
>
> The default page is below.
>
> <html>
> <body onload="moduleDidLoad()">
> <object id = "blah"/>
>  <script>
>     function moduleDidLoad() {
>        id = document.getElement("blah");
>        // Call some function on id
>     }
>
>     function urlLoad(url) {
>     }
>  </script>
> </html>
>
> Chrome also has an extension associated with it.
> This extension has a java script file tagged as background.
> It intercepts the url.
> So when the user typeswww.google.com, I need to send the urlwww.google.comto urlLoad function in page A and prevent the new page
> associated withwww.google.comfrom getting loaded. I need chrome to
Reply all
Reply to author
Forward
0 new messages