1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-03 10:14:13 +01:00

Add support for regexp site-filters to :style.

This commit is contained in:
Kris Maglione
2011-06-19 10:56:16 -04:00
parent c3d5e7bb74
commit 5684be9b36
3 changed files with 14 additions and 10 deletions

View File

@@ -152,9 +152,9 @@
<p>
Add CSS styles to the browser or to web pages. <a>filter</a> is a
comma-separated list of <t>site-filters</t> for which the style will
apply. Regular expression filters may not be used and the <tt>!</tt>
character may not be used to invert the sense of the match.
<oa>css</oa> is a full CSS rule set (e.g., <tt>body { color: blue; }</tt>).
apply. The <tt>!</tt> character may not be used to invert the sense
of the match. <oa>css</oa> is a full CSS rule set (e.g., <tt>body {
color: blue; }</tt>).
</p>
<p>The following options are available:</p>

View File

@@ -68,17 +68,20 @@ update(Sheet.prototype, {
get fullCSS() {
let filter = this.sites;
let css = this.css;
let preamble = "/* " + this.uri + (this.agent ? " (agent)" : "") + " */\n\n" + namespace + "\n";
if (filter[0] == "*")
return namespace + css;
return preamble + css;
let selectors = filter.map(function (part)
(/[*]$/.test(part) ? "url-prefix" :
/[\/:]/.test(part) ? "url"
: "domain")
+ '("' + part.replace(/"/g, "%22").replace(/\*$/, "") + '")')
!/^(?:[a-z-]+:|[a-z-.]+$)/.test(filter) ? "regexp(" + part.quote() + ")" :
(/[*]$/.test(part) ? "url-prefix" :
/[\/:]/.test(part) ? "url"
: "domain")
+ '("' + part.replace(/"/g, "%22").replace(/\*$/, "") + '")')
.join(",\n ");
return "/* " + this.uri + (this.agent ? " (agent)" : "") + " */\n\n"
+ namespace + "\n@-moz-document " + selectors + " {\n\n" + css + "\n\n}\n";
return preamble + "@-moz-document " + selectors + " {\n\n" + css + "\n\n}\n";
}
});