1

I created a Firefox add-on, the point is that Youtube is built into the side and adds an extra button. A key role is just enough to redirect to another page of youtube link.

The problem is that when changing the youtube video url does not change, but remains above the header change, but not the button. You can, however, be updated properly when I update the page (F5).

What I mean is that the supply is not updated during its navigation on Youtube.

Here is the content of the file main.js which invite the executive file:

var pageMod = require("page-mod");
var self = require("self");
pageMod.PageMod({
  include: "*.youtube.com",
  contentScriptFile: self.data.url("youtube.js")
});

My question is, how should it be changed so that during navigation in the Youtube freshen the accessories as well?

Thanks in advance!

Best Regards Davee

Noitidart
  • 35,443
  • 37
  • 154
  • 323
Davee
  • 21
  • 2

3 Answers3

1

I copied my code currently looks like this, but unfortunately if there is for the code snippet does not work.

think so?

main.js:

var pageMod = require("page-mod");
var self = require("self");
pageMod.PageMod({
  include: "*.youtube.com",
  contentScriptFile: self.data.url("youtube.js")
});

var progListener = {
    onLocationChange: function (aProgress, aRequest, aURI, aFlags) {
        Cu.reportError('location changed!');
        if (aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT) {
            Cu.reportError('anchor clicked!');
        } else {
            return
        }
        var domWin = aProgress.DOMWindow;
        var domDoc = domWin.document;
        if(!domDoc) {
            Cu.reportError('document not loaded yet');
            return;
        }
    }
}

Services.wm.getMostRecentWindow('navigator:browser').gBrowser.addProgressListener(progListener);
Davee
  • 21
  • 2
  • at the top of your code stick this in ```var { Cc, Ci, Cu, Cr } = require("chrome");``` – Noitidart Feb 26 '14 at 18:18
  • if it still doesnt work please upload a xpi version of your addon and ill take a look at it – Noitidart Feb 26 '14 at 18:19
  • Will take a look later today. Did you add in the var {Cc, Ci.... stuff at the top and the upload xpi? thats important for me to help you. – Noitidart Feb 27 '14 at 18:22
  • I copied the last code you sent, but not so good unfortunately, mediafire linkről you can download the XPI file in the link above to post a comment. Thanks. – Davee Feb 28 '14 at 15:54
  • ok ill download your code today and upload a working version of your xpi, please add the ```var {Cc, Ci, Cu} = require('chrome');``` if its not already there in the xpi. Ill take a look later today I didnt get a chance yesterday. – Noitidart Feb 28 '14 at 16:59
  • I added the code you wrote earlier, the first line of the main.js copied, but unfortunately it does not run the add. xpi file you uploaded is already included in that. – Davee Feb 28 '14 at 17:31
  • ah ok great as long as the require chrome line is there i can help you. ill get back to you by end of today for sure i have some time :) – Noitidart Feb 28 '14 at 17:36
  • Hey man Im home from work Ill try to look at it tonight, just making some dinner and stuff, forgive the delay bro – Noitidart Mar 01 '14 at 08:56
  • hey man im working on this now. When I install your addon it says this error `Module: keptelenseg/main has no authority to load: chrome` you have to give it permission same way you gave it permisson to use `var pageMod = require("page-mod");`, i dont know how thats done as i dont know sdk, do you know how to fix that? – Noitidart Mar 05 '14 at 10:46
  • actually dude you dont need progressEventListener the pageMod thing works fine, i uploaded [HERE](https://www.dropbox.com/s/wsf8afq79qwtw5w/22022556.xpi) with an alert message to show you its work. One thing to note though, it fires multiple times because of frames in the document loaidng, you might want to check if it's a frame by going `if (document.defaultView.frameElement) { /*its a frame*/ }` – Noitidart Mar 05 '14 at 10:54
  • note the pop-up windows you the information I have added the main.js file a request with chrome, but still not good, in fact not even play, so it will not show you where the button should be there. I have no idea unfortunately, I wish only to achieve, while the youtube navigation always enabled video time, not only when the whole page is updated, since now the youtube somehow solved that js-to navigating without refresh page within the site, this is not detected by the supplement. – Davee Mar 09 '14 at 16:55
  • hm i dont understand can you give me exact steps to reproduce with the code you gave me – Noitidart Mar 09 '14 at 21:54
  • hard to explain, if you try to add the youtube page and point out the button next to the upload button in the link you see the video id when you switch to another video, it is still time left in the previous video in the link, because the options are not updated for I'm looking for a solution. :) – Davee Mar 10 '14 at 15:59
  • i want to help you but i really dont understand. can you like make a youtube video or something or tell me exactly how to replicate the issue. i want to help badly but i dont understand. i think its very fixable – Noitidart Mar 11 '14 at 05:26
0

you have to use onLocationChange

var progListener = {
    onLocationChange: function (aProgress, aRequest, aURI, aFlags) {
        Cu.reportError('location changed!');
        if (aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT) {
            Cu.reportError('anchor clicked!');
        } else {
            return
        }
        var domWin = aProgress.DOMWindow;
        var domDoc = domWin.document;
        if(!domDoc) {
            Cu.reportError('document not loaded yet');
            return;
        }
    }
}

browserDOMWindow.gBrowser.addProgressListener(progListener);
Noitidart
  • 35,443
  • 37
  • 154
  • 323
  • This code was signed by them in the main.js file to be copied? We apologize for this misunderstanding is measured, but by making Firefox Add-ons I'm just learning ... Thank you! – Davee Feb 24 '14 at 15:58
  • hi davee i dont understand your reply, did you get it working? – Noitidart Feb 25 '14 at 05:48
  • I do not fully understand the code snippet you sent, to be added, or you just need to copy the file main.js? Thanks. – Davee Feb 25 '14 at 16:40
  • yes attach this to the gBrowser of the window, then everytime the url changes in any tab you will be notified. even if it is youtube. but if you copy paste this into main.js change the ```browserDOMWindow``` to ```Services.wm.getMostRecentWindow('navigator:browser')``` ill make a demo for your later on – Noitidart Feb 25 '14 at 16:51
0

Hey @Davee I think i figured this out. Actually youtube is using pushtate stuff.

Did you ever figure it out? See this topic here: Chrome extension is not loading on browser navigation at YouTube

Community
  • 1
  • 1
Noitidart
  • 35,443
  • 37
  • 154
  • 323