Strange pagemod issue

Hi!

This is my code:

require("sdk/page-mod").PageMod({
    include:"*.freegamehosting.eu",
    contentStyle:"a[onclick*=\"document.cookie\"] {background:red !important}",
    contentScript:"console.log(\"test\");"
});

For some reason contentScript doesn’t work at www.freegamehosting.eu but CSS is applied well. i think there’s nothing wrong with the code, it works on other domains, with http and https. Does anybody has a clue why it doesn’t work?

Is the site using frames maybe?

no iframes. in that case css wouldn’t be applied either, but it is.

can someone please try the code and tell me if the issue really exists?

I see “test” getting logged multiple times, seems to work.

I see it too, everywhere except on the homepage before i click “accept cookies” button, and that’s the only page where i need it to work. can you please confirm this or does it work there when you open it?

Why didn’t you say that before :expressionless:

It does indeed not work on the “accept cookies” page.
Something fishy is going on here.
When I go to their page from a fresh new tab, the url bar gets cleared and window.location gives “about:blank”.
Maybe they are messing with the history api or something.
They don’t seem to be playing nice.

Well, I didn’t notice it before :innocent:

I found out what stops the pageMod: window.stop() function, here: https://www.freegamehosting.eu/js/cookies.js

When removed, it works fine. Perhaps it shouldn’t have any effect on javascript running inside addons, so this behavior may be a bug.

btw, is there a way to run some javascript earlier? ie, i’d like to set a cookie before website’s cookie checking script runs. as far as my knowledge goes, i can only manipulate it after.

I think you should check this out:
https://developer.mozilla.org/en-US/Add-ons/Code_snippets/Progress_Listeners

And the sdk has a nice module for matching the address:
https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/util_match-pattern