2291
1
0
0
像这样的
<script>
let bfJs = document.getElementsByClassName('bf_js')[0]
let mainData = `<p>
<img src="/static/images/a2.jpg" title="/pic-class/dada1a7eeef39be0e12026293f1faa44/1.jpg" /></p>
<p>
<img src="/static/images/a2.jpg" title="/pic-class/dada1a7eeef39be0e12026293f1faa44/2.jpg" /></p>
<p>
<img src="/static/images/a2.jpg" title="/pic-class/dada1a7eeef39be0e12026293f1faa44/3.jpg" /></p>
<p>
<img src="/static/images/a2.jpg" title="/pic-class/dada1a7eeef39be0e12026293f1faa44/4.jpg" /></p>
<p>
<img src="/static/images/a2.jpg" title="/pic-class/dada1a7eeef39be0e12026293f1faa44/5.jpg" /></p>
<p>
<img src="/static/images/a2.jpg" title="/pic-class/dada1a7eeef39be0e12026293f1faa44/6.jpg" /></p>
<p>
<img src="/static/images/a2.jpg" title="/pic-class/dada1a7eeef39be0e12026293f1faa44/7.jpg" /></p>
<p>
<img src="/static/images/a2.jpg" title="/pic-class/dada1a7eeef39be0e12026293f1faa44/8.jpg" /></p>
<p>
<img src="/static/images/a2.jpg" title="/pic-class/dada1a7eeef39be0e12026293f1faa44/9.jpg" /></p>
<p>
<img src="/static/images/a2.jpg" title="/pic-class/dada1a7eeef39be0e12026293f1faa44/10.jpg" /></p>
<p>
<img src="/static/images/a2.jpg" title="/pic-class/dada1a7eeef39be0e12026293f1faa44/11.jpg" /></p>
<p>
<img src="/static/images/a2.jpg" title="/pic-class/dada1a7eeef39be0e12026293f1faa44/12.jpg" /></p>
<p>
<img src="/static/images/a2.jpg" title="/pic-class/dada1a7eeef39be0e12026293f1faa44/13.jpg" /></p>
`
if (mainData.indexOf('title=')==-1) {
console.log(mainData.indexOf('/pic-class/'));
if (mainData.indexOf('/pic-class/')!==-1) {
let regPicObj = new RegExp('/pic-class/', "g");
var newstr=mainData.replace(regPicObj,fullURL+'pic-class/');
bfJs.innerHTML = newstr
console.log(newstr);
}else if (mainData.indexOf('/image/')!==-1) {
let imageObj = new RegExp('/image/', "g");
var newstr=mainData.replace(imageObj,fullURL);
bfJs.innerHTML = newstr
console.log(newstr);
}
}else{
bfJs.innerHTML = mainData
}
// 图片域名
if (fullURL) {
let strTitlea = document.getElementsByClassName('bf_js')[0].getElementsByTagName('img')
let searchTextc = window.location.origin+'/image/'
let searchClass = window.location.origin+'/pic-class/'
let regExpc = new RegExp(searchTextc, "g");
let regPicExpc = new RegExp(searchClass, "g");
for (let index = 0; index < strTitlea.length; index++) {
let html = strTitlea[index].src;
let titleData = strTitlea[index].title
let lvchaHtml = '';
let lvchaPicHtml = '';
if(titleData){
titleData = window.location.origin+titleData
if (titleData.indexOf(searchTextc)!=-1) {
lvchaHtml = titleData.replace(regExpc,fullURL);//将找到的关键字替换,加上highlight属性;
strTitlea[index].src=lvchaHtml;
} else if (titleData.indexOf(searchClass)!=-1) {
lvchaPicHtml = titleData.replace(regPicExpc,fullURL+'/pic-class/');//将找到的关键字替换,加上highlight属性;
strTitlea[index].src=lvchaPicHtml;
}
}else if(html){
if (html.indexOf(searchTextc)!=-1) {
lvchaHtml = html.replace(regExpc,fullURL);//将找到的关键字替换,加上highlight属性;
strTitlea[index].src=lvchaHtml;
} else if (html.indexOf(searchClass)!=-1) {
lvchaPicHtml = html.replace(regPicExpc,fullURL+'/pic-class/');//将找到的关键字替换,加上highlight属性;
strTitlea[index].src=lvchaPicHtml;
}
}
}
}
</scrip