1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-04 22:45:46 +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> <p>
Add CSS styles to the browser or to web pages. <a>filter</a> is a 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 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> apply. The <tt>!</tt> character may not be used to invert the sense
character may not be used to invert the sense of the match. of the match. <oa>css</oa> is a full CSS rule set (e.g., <tt>body {
<oa>css</oa> is a full CSS rule set (e.g., <tt>body { color: blue; }</tt>). color: blue; }</tt>).
</p> </p>
<p>The following options are available:</p> <p>The following options are available:</p>

View File

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

View File

@@ -90,6 +90,7 @@
and linking to source code locations). [b4] and linking to source code locations). [b4]
- :downloads now opens a download list in the multi-line output - :downloads now opens a download list in the multi-line output
buffer. Added -sort flag. [b6][b7] buffer. Added -sort flag. [b6][b7]
- :style now supports regexp site-filters on Firefox 6+. [b7]
- :qa closes only the current window, per Vim. [b7] - :qa closes only the current window, per Vim. [b7]
- Added :exit command. [b7] - Added :exit command. [b7]
- Added :dlclear command. [b7] - Added :dlclear command. [b7]