| 1 |
javascript:(function() { |
| 2 |
var d = document |
| 3 |
,uris = [] |
| 4 |
,i = 0 |
| 5 |
,o |
| 6 |
,home = (location + '').split('/').splice(0, 3).join('/') + '/'; |
| 7 |
function add(uri) { |
| 8 |
if (0 !== uri.indexOf(home)) { |
| 9 |
return; |
| 10 |
} |
| 11 |
uri = uri.replace(/\?.*/, ''); |
| 12 |
uris.push(escape(uri.substr(home.length))); |
| 13 |
}; |
| 14 |
function sheet(ss) { |
| 15 |
// we must check the domain with add() before accessing ss.cssRules |
| 16 |
// otherwise a security exception will be thrown |
| 17 |
if (ss.href && add(ss.href) && ss.cssRules) { |
| 18 |
var i = 0, r; |
| 19 |
while (r = ss.cssRules[i++]) |
| 20 |
r.styleSheet && sheet(r.styleSheet); |
| 21 |
} |
| 22 |
}; |
| 23 |
while (o = d.getElementsByTagName('script')[i++]) |
| 24 |
o.src && !(o.type && /vbs/i.test(o.type)) && add(o.src); |
| 25 |
i = 0; |
| 26 |
while (o = d.styleSheets[i++]) |
| 27 |
/* http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-DocumentStyle-styleSheets |
| 28 |
document.styleSheet is a list property where [0] accesses the 1st element and |
| 29 |
[outOfRange] returns null. In IE, styleSheets is a function, and also throws an |
| 30 |
exception when you check the out of bounds index. (sigh) */ |
| 31 |
sheet(o); |
| 32 |
if (uris.length) |
| 33 |
window.open('%BUILDER_URL%#' + uris.join(',')); |
| 34 |
else |
| 35 |
alert('No js/css files found with URLs within "' |
| 36 |
+ home.split('/')[2] |
| 37 |
+ '".\n(This tool is limited to URLs with the same domain.)'); |
| 38 |
})(); |