我写了一个脚本,改变设计糟糕的页面上的CSS元素。我一直在使用Chrome进行测试,现在它功能齐全。我已经把它在网络上,我现在用这个作为书签文字:小书签不起作用在Firefox
javascript:(function(){document.body.appendChild(document.createElement('script')).src='http://myexamplewebsite.com/files/adjustPage.js';})();
它完全在Chrome,但在最新的Firefox或IE浏览器无法正常工作。我查看了Chrome和Firefox的错误控制台,没有人抱怨任何问题。当我将代码放入错误控制台的“代码”字段并进行评估时,Firefox也不会作出反应。
Firefox没有说在底部的小状态栏:“读myexamplewebsite.com”,但没有别的。
这是不是在我上面跑的书签码怪癖,因为我已经放在一个“你好世界”脚本在同一台服务器上,并且它工作得很好。
有没有更好的方式来制定出什么样的Firefox/IE不喜欢我的剧本?
如果你有兴趣,我运行的代码是在这里。请原谅代码的丑陋,这是一个非常快速和肮脏的黑客:
var section = document.getElementsByClassName('cqGroupBox');
for(var i in section) {
var children = section[i].childNodes;
for(var j in children){
if(children[j].innerText == 'Detected on configuration') {
var style = section[i].getAttribute('style');
style += ' display:none;';
section[i].setAttribute('style', style);
break;
}
}
}
var tables = document.getElementsByTagName('table');
for(var i in tables) {
try{
var styleNode = tables[i].attributes.getNamedItem('style');
var style = styleNode.firstChild.nodeValue;
if(style == null) {
continue;
}
if(style.match('top: 434px; left: 120px;')
|| style.match('top: 461px; left: 120px;')
|| style.match('top: 434px; left: 456px;')
|| style.match('top: 461px; left: 456px;')){
style += ' display:none;';
tables[i].attributes.getNamedItem('style').firstChild.nodeValue = style;
}
} catch(err){continue;}
}
var labels = document.getElementsByTagName('label');
for(var i in labels) {
try{
var styleNode = labels[i].attributes.getNamedItem('style');
var style = styleNode.firstChild.nodeValue;
if(style == null) {
continue;
}
if(labels[i].innerText == 'OS'
|| labels[i].innerText == 'App. Server'
|| labels[i].innerText == 'DBMS'
|| labels[i].innerText == 'Web Server'){
style += ' display:none;';
labels[i].attributes.getNamedItem('style').firstChild.nodeValue = style;
}
} catch(err){continue;}
}
var divs = document.getElementsByTagName('div');
for(var i in divs) {
try {
var styleNode = divs[i].attributes.getNamedItem('style');
var style = styleNode.firstChild.nodeValue;
if(style == null) {
continue;
}
if(style.match('top: 291px; left: 23px;')){
style.replace('height: 109px;','');
divs[i].attributes.getNamedItem('style').firstChild.nodeValue = style;
innerDivs = divs[i].getElementsByTagName('div');
for(var j in innerDivs){
try {
innerStyle = innerDivs[j].attributes.getNamedItem('style').firstChild.nodeValue;
if(innerStyle.match('width: 665px; height: 109px;')){
innerStyle = innerStyle.replace('height: 109px;','');
innerStyle += ' font-size: 130%';
innerDivs[j].attributes.getNamedItem('style').firstChild.nodeValue = innerStyle;
}
} catch(err){continue;}
}
}
} catch(err){continue;}
}
似乎不错,但也许它不符合您的检查;)也许这就是计算的风格,而不是那个html plage服务的那个:)我们需要这个脚本应该被触发的页面 – walialu
好点。我看到页面上的尺寸都是绝对的,并且假定它们会被硬编码(页面是_that_ bad)。我无法共享该页面,因为它是一个专有系统(ClearQuest错误跟踪系统),但您对我所能找到的内容有任何建议吗? – HXCaine