How to develop custom filters for the Imagus hover zoom extension?

后端 未结 1 1552
长情又很酷
长情又很酷 2021-02-01 08:12

After I read about Hover Zoom being evil (yikes!), two articles made me instantly switch to another one, called Imagus:

  • Hoverzoom’s Malware controversy, and Imagus
相关标签:
1条回答
  • 2021-02-01 08:35

    The fieds can contain a JavaScript function or a Regex.

    • link recives the address of any link you hover over.
    • url uses captured parentheses values from the link field to make an url.
    • res recives whatever page, in text, that was pointed to by url or link.

    If one of them is empty, that step is skipped, e.g. no url and res just loads from link's output.
    A simple example is the xkcd filter:
    link:

    ^(xkcd\.(?:org|com)/\d{1,5})/?$
    

    Finds links to xkcd comics. If you're unfamiliar with regex, anything between the parentheses is saved and can be used in Imagus as "$n" to refer to the nth capture. Note that if there's a "?:" after the first parentheses it wont get captured.

    url:

    $1/info.0.json
    

    This simply appends "/info.0.json" to the address from link.

    res:

    :
    if ($._[0] != '{') $ = null;
    else $ = JSON.parse($._), $ = [$.img, [$.year, ('0'+$.month).slice(-2),
    ('0'+$.day).slice(-2)].join('-') + ' | ' + $.safe_title + ' - ' + $.alt + ' ' +
    $.link];
    return $;
    

    This javascript function parses the JSON file and returns an array where the first element is the link and the second is the caption text displayed under the hoverzoomed image. If you return just a link then the caption will be the alt text of the link.

    • img is used as link is, but for image sources
    • to is used as res or url is

    A simple use case is when you want to redirect from thumbnails to hires. Like the filter for wikimapia.org.
    img:

    ^(photos\.wikimapia\.org/p/[^_]+_(?!big))[^.]+
    

    This finds any wikimapia image that doesn't have big in the name.
    to:

    $1big
    

    Adds big to the url.

    • note is just for notes.

    Some filters have links to API docs here.

    Now, there's no documentation for this feature yet so I probably missed a lot, but hopfully it'll be enough.

    Cheers.

    0 讨论(0)
提交回复
热议问题