MCPcopy Create free account
hub / github.com/hoothin/UserScripts / parsePics

Function parsePics

RandomSexyPic/randomSexyPic.user.js:305–327  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

303 var leftNum=searchNum;
304 r18Check.style.display=sfwCheck.style.display=r18CheckLabel.style.display=sfwCheckLabel.style.display="none";
305 let parsePics=(data)=>{
306 let picUrls=[],urlReg=/(https?|ftp|file):\/\/[\-A-Za-z0-9\+&@#/%?=~_\|!:,\.;]+[\-A-Za-z0-9\+&@#/%=~_\|]/g;
307 if(typeof data == "string"){
308 picUrls=data.match(urlReg);
309 }else{
310 let checkJson=obj=>{
311 for(let i in obj){
312 if(typeof obj[i] == "string"){
313 let pics=obj[i].match(urlReg);
314 if(pics)picUrls=picUrls.concat(pics);
315 }else checkJson(obj[i]);
316 }
317 };
318 checkJson(data);
319 }
320 if(picUrls){
321 picUrls=picUrls.filter((item, index) => picUrls.indexOf(item) === index);
322 picUrls.forEach(url=>{
323 leftNum--;
324 createImg(unescape(url));
325 });
326 }
327 }
328 parsePics(jsonData);
329 processByTime(leftNum||1, loadNum=>{
330 let href=location.href.replace(/num=\d+(&time=\d+)?/,"num="+loadNum+"&time="+Date.now()),postParams=href.match(/#p{(.*)}/);

Callers 1

Calls 2

checkJsonFunction · 0.85
createImgFunction · 0.85

Tested by

no test coverage detected