Reduce redundant code for changing image links.

This commit is contained in:
ccd0 2017-01-05 18:15:19 -08:00
parent c5f175ed13
commit b32735322f

View File

@ -26,8 +26,7 @@ Build.Test =
href = el.href
href = href.replace /(^\w+:\/\/boards.4chan.org\/[^\/]+\/thread\/\d+)\/.*/, '$1'
el.setAttribute 'href', href
for el in $$ '.fileText > a, a.fileThumb', root2 when ImageHost.regex.test(el.hostname)
el.hostname = 'i.4cdn.org'
ImageHost.fixLinks $$('.fileText > a, a.fileThumb', root2)
for el in $$ 'img[src]', root2
el.src = el.src.replace /(spoiler-\w+)\d(\.png)$/, '$11$2'
for el in $$ 'pre.prettyprinted', root2