On 7/18/12 5:33 PM, CIAvash wrote:
>> For what I can see, `checkScript` needs to be attached in anycase, if
>> "this is the page we want" condition have to check the content of the
>> page, to determined if that is the page we want. So basically,
>> `checkScript` *is* a "content script", that needs to be attached to
>> every pages, so nothing is changed.
> Yes. But it can be a simple and small condition.
As soon as the condition needs to check the content of the page, it
really doesn't matter, the script needs to be attached to the page;
therefore will be a "content script".
> And it will prevent any confliction.
What kind of confliction?
> If we don't use a "checkScript",
You can use a "checkScript", but it's nothing more than a
"contentScript". You could use a pageMod with a tiny contentScript that
check your condition, and then attach the bigger contentScript using
`tab.attach`.
> 2. Style from content style will apply on every page so we must use a
> unique CSS class to prevent confliction.
If you're using the "*" in include to filter manually later the page
with JS, then probably you should apply the stylesheet with JavaScript
as well.
We are working on improving `contentStyle`, but from this point of view
it will still behave like now, if you're using "*".
As workaround you could use the tab's title to limit the page where you
attach your content script; but if you need a reliable method I will
suggest to you to use low level APIs to determined if the tab is
displaying an image.
In any case, to me `pageMod` is not the tool you have to use, because it
based on URLs, and your criteria is not URL based. Probably `tabs`
module is more appropriate for what you want to achieve.
Maybe we could think about adding a `mimeType` property in `tabs` API,
in order to check the type of document currently loaded (and with
PDF.js, the image viewer, and so on, it could be useful I guess).