0

I am having trouble getting my extension to redirect some urls.

This is the object I am trying to get to redirect:

<object type="application/x-shockwave-flash" id="ytp" data="http://www.youtube.com/v/GVwh8FEsWUk?start=0&amp;version=3&amp;autoplay=1&amp;border=0&amp;cc_load_policy=0&amp;controls=0&amp;disablekb=1&amp;egm=0&amp;enablejsapi=1&amp;hd=1&amp;iv_load_policy=3&amp;modestbranding=1&amp;playerapiid=ytp&amp;rel=0&amp;showinfo=0&amp;showsearch=0" width="100%" height="100%"><param name="quality" value="high"><param name="wmode" value="opaque"><param name="allowScriptAccess" value="always"><param name="allowFullScreen" value="false"><param name="bgcolor" value="#000000"></object>

It exists on yt-plg.appspot.com

manifest.json (with some omitted bits):

"background" : {
    "scripts": ["resources/js/events-bg.js"]
},
...
"permissions": [
    "*://*.plug.dj/*",
    "http://plug.myuplay.com/*",
    "http://yt-plg.appspot.com/*",
    "webRequest",
    "storage",
    "notifications",
    "contextMenus"
],

events-bg.js:

chrome.webRequest.onBeforeRequest.addListener(
        function(details) {
            if (details.url.indexOf("html5=1")!=-1) return {};
            console.log(details.url);
            return {
                redirectUrl: details.url.replace("&?html5=[(true|false)01]","") + "&html5=1"
            };
        },
        {
            urls: ["http://www.youtube.com/v/*"]
        },
        ["blocking"]
);

Essentially, my goal is to force html5 on this player. If this is not possible to do this in this fashion, I can always use code injection and do it what way. What is wrong with my present setup?

Notes: Currently the request listener is never triggered. I have set breakpoints in it and used the console logging to test this.

Update:

After screwing around in the permissions I have created a basic webRequest that should be triggered on any url but I am still not getting any results. I am going to just assume that this API needs some work still and that this is not well documented enough to see what is going wrong. I have no output whatsoever on my background page and no urls are being fixed. I will manually inject code to correct my issue instead until this can be sorted out.

Tyler Scott
  • 1,046
  • 17
  • 33
  • You need to declare the `webRequestBlocking` permission in your manifest file. If you [opened the console for the background page](http://stackoverflow.com/questions/10257301/where-to-read-console-messages-from-background-js-in-a-chrome-extension/10258029#10258029), you would have seen the relevant error message. – Rob W Jan 12 '14 at 10:55
  • Didn't see any error messages. No messages of any kind were triggered sadly. – Tyler Scott Jan 13 '14 at 11:54

0 Answers0