잘못 설계된 페이지의 CSS 요소를 변경하는 스크립트를 작성했습니다. 내가 크롬을 시험해 보았을 때, 이제는 완벽하게 작동합니다. 나는 웹에 배치 한 지금 북마크 텍스트로 이것을 사용하고 있습니다 :북마크가 Firefox에서 작동하지 않습니다.
이javascript:(function(){document.body.appendChild(document.createElement('script')).src='http://myexamplewebsite.com/files/adjustPage.js';})();
그것은 크롬에 완벽하게 작동하지만 최신 파이어 폭스 나 IE에서 작동하지 않습니다. 크롬과 파이어 폭스의 오류 콘솔을 살펴본 결과 어떤 문제도 불평하지 않습니다. Firefox는 오류 콘솔의 'code'필드에 코드를 입력하고 평가할 때도 반응하지 않습니다.
Firefox는 하단의 작은 상태 표시 줄에서 "Read myexamplewebsite.com"이라고 말합니다.하지만 그 밖의 것은 없습니다.
같은 서버에 'hello world'스크립트를 배치했기 때문에 위에서 실행중인 북마크릿 코드의 버킷이 아닙니다. 정상적으로 작동했습니다.
내 스크립트에 대해 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;}
}
이 좋은 것 등, 게코 DOM을 볼 수 있지만, 어쩌면 수표와 일치하지 않습니다 html plage가 제공하는 것 :)이 스크립트가 실행되어야하는 페이지가 필요합니다. – walialu
좋은 지적입니다. 페이지의 크기가 모두 절대적이며 하드 코딩 된 것으로 가정합니다 (페이지가 좋지 않음). 독점 시스템 (ClearQuest 버그 추적 시스템)이기 때문에 나는 페이지를 공유 할 수 없지만 내가 찾을 수있는 것에 대한 제안이 있습니까? – HXCaine