Sleazy Fork is available in English.

Handy Image

Shows just fullsize Image with hotkeys & without pop-ups on many image-hosting sites

< Handy Image 피드백

질문/댓글

FFW
§
작성: 2015-06-12
수정: 2015-06-12

Two possibilities

Is there a way to tell the script to try and if it fails to find an image try another.

example i.src = i.content.replace('thumb','org') if it fails try i.src = i.content.replace('thumb','hd')

Owyn개발자
§
작성: 2015-06-12

there is no image finding in lines you gave here, those just replace part of content, 'finding' an image isn't about guessing it - it's about actually finding it - look for it in pages source and make a way for script to pick it.

FFW
§
작성: 2015-06-12
수정: 2015-06-12

That was just the last part :P

case "example.com":
    i = document.head.querySelector('meta[property="og:image"]');
    if(i){
               i.src = i.content.replace('thumb','org'); // if it fails  to build the image try 
                                            // i.src = i.content.replace('thumb','hd')
            }
    break;

Like building an array of possibilities and going through it. Is it possible?

Jixun.Moe관리자
§
작성: 2015-06-12
i.tryIndex = 0;
i.rules = [['thumb', 'org'], ['thumb', 'hd']];

function nextRule() {
  var index = i.tryIndex++;
  if (index >= i.rules.length) {
    console.error('I tried, give up.');
    return ;
  }
  i.src = i.content.replace(i.rules[index][0], i.rules[index][1]);
};
i.onerror = nextRule;
nextRule ();

Not tested though... Don't know if it will fire standard onerror event.

FFW
§
작성: 2015-06-12
수정: 2015-06-12

@JixunMoe Doesn't seem to be working. Would always use the first option in the array. Thank you for writing that though :)

댓글 남기기

댓글을 남기려면 로그인하세요.