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:
@@ -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>
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user