mirror of
https://github.com/mrclay/minify.git
synced 2025-08-12 00:54:35 +02:00
Improved builder bookmarklet
This commit is contained in:
@@ -1,22 +1,23 @@
|
|||||||
javascript:(function() {
|
javascript:(function() {
|
||||||
function add(uri) {
|
|
||||||
(0 === uri.indexOf(home))
|
|
||||||
&& (!/[\?&]/.test(uri))
|
|
||||||
&& uris.push(escape(uri.substr(home.length)));
|
|
||||||
}
|
|
||||||
function sheet(ss) {
|
|
||||||
ss.href && add(ss.href);
|
|
||||||
if (ss.cssRules) {
|
|
||||||
var i = 0, r;
|
|
||||||
while (r = ss.cssRules[i++])
|
|
||||||
r.styleSheet && sheet(r.styleSheet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var d = document
|
var d = document
|
||||||
,uris = []
|
,uris = []
|
||||||
,i = 0
|
,i = 0
|
||||||
,o
|
,o
|
||||||
,home = (location + '').split('/').splice(0, 3).join('/') + '/';
|
,home = (location + '').split('/').splice(0, 3).join('/') + '/';
|
||||||
|
function add(uri) {
|
||||||
|
return (0 === uri.indexOf(home))
|
||||||
|
&& (!/[\?&]/.test(uri))
|
||||||
|
&& uris.push(escape(uri.substr(home.length)));
|
||||||
|
};
|
||||||
|
function sheet(ss) {
|
||||||
|
// we must check the domain with add() before accessing ss.cssRules
|
||||||
|
// otherwise a security exception will be thrown
|
||||||
|
if (ss.href && add(ss.href) && ss.cssRules) {
|
||||||
|
var i = 0, r;
|
||||||
|
while (r = ss.cssRules[i++])
|
||||||
|
r.styleSheet && sheet(r.styleSheet);
|
||||||
|
}
|
||||||
|
};
|
||||||
while (o = d.getElementsByTagName('script')[i++])
|
while (o = d.getElementsByTagName('script')[i++])
|
||||||
o.src && !(o.type && /vbs/i.test(o.type)) && add(o.src);
|
o.src && !(o.type && /vbs/i.test(o.type)) && add(o.src);
|
||||||
i = 0;
|
i = 0;
|
||||||
@@ -25,5 +26,7 @@ javascript:(function() {
|
|||||||
if (uris.length)
|
if (uris.length)
|
||||||
window.open('%BUILDER_URL%#' + uris.join(','));
|
window.open('%BUILDER_URL%#' + uris.join(','));
|
||||||
else
|
else
|
||||||
alert('No minifiable resources found.');
|
alert('No js/css files found with URLs within "'
|
||||||
|
+ home.split('/')[2]
|
||||||
|
+ '".\n(This tool is limited to URLs with the same domain.)');
|
||||||
})();
|
})();
|
Reference in New Issue
Block a user