"Change Use Faster Image Host setting to Override 4chan Image Host in Advanced menu, which can be set to whichever image host you want to use. #2046
This commit is contained in:
parent
57a5509765
commit
566c8bffd0
@ -493,6 +493,9 @@ Settings =
|
||||
if data['sauces']?
|
||||
set 'sauces', data['sauces'].replace(/^(#?\s*)(?:http:)?\/\/(www\.pixiv\.net|www\.deviantart\.com|imgur\.com|flickr\.com)\//mg, '$1https://$2/')
|
||||
set 'sauces', data['sauces'].replace(/https:\/\/yandex\.com\/images\/search\?rpt=imageview&img_url=%IMG/g, 'https://yandex.com/images/search?rpt=imageview&url=%IMG')
|
||||
if compareString < '00001.00014.00009.00001'
|
||||
if data['Use Faster Image Host']? and not data['fourchanImageHost']?
|
||||
set 'fourchanImageHost', (if data['Use Faster Image Host'] then 'i.4cdn.org' else '')
|
||||
changes
|
||||
|
||||
loadSettings: (data, cb) ->
|
||||
@ -559,7 +562,7 @@ Settings =
|
||||
$.id('lastarchivecheck').textContent = 'never'
|
||||
|
||||
items = {}
|
||||
for name in ['archiveLists', 'archiveAutoUpdate', 'captchaLanguage', 'captchaServiceDomain', 'boardnav', 'time', 'timeLocale', 'backlink', 'pastedname', 'fileInfo', 'QR.personas', 'favicon', 'usercss', 'customCooldown', 'jsWhitelist']
|
||||
for name in ['archiveLists', 'archiveAutoUpdate', 'fourchanImageHost', 'captchaLanguage', 'captchaServiceDomain', 'boardnav', 'time', 'timeLocale', 'backlink', 'pastedname', 'fileInfo', 'QR.personas', 'favicon', 'usercss', 'customCooldown', 'jsWhitelist']
|
||||
items[name] = Conf[name]
|
||||
input = inputs[name]
|
||||
event = if name in ['archiveLists', 'archiveAutoUpdate', 'QR.personas', 'favicon', 'usercss'] then 'change' else 'input'
|
||||
@ -575,6 +578,10 @@ Settings =
|
||||
Settings[key].call input
|
||||
return
|
||||
|
||||
listImageHost = $.id 'list-fourchanImageHost'
|
||||
for textContent in ImageHost.suggestions
|
||||
$.add listImageHost, $.el 'option', {textContent}
|
||||
|
||||
$.on inputs['captchaServiceKey'], 'input', Settings.captchaServiceKey
|
||||
$.get 'captchaServiceKey', Conf['captchaServiceKey'], ({captchaServiceKey}) ->
|
||||
Conf['captchaServiceKey'] = captchaServiceKey
|
||||
|
||||
@ -19,6 +19,13 @@
|
||||
<button id="update-archives">Update now</button> Last updated: <time id="lastarchivecheck"></time> <label><input type="checkbox" name="archiveAutoUpdate"> Auto-update</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Override 4chan Image Host</legend>
|
||||
<div>Change 4chan image links to this domain. Leave blank for no change.</div>
|
||||
<div><input name="fourchanImageHost" class="field" spellcheck="false" list="list-fourchanImageHost"></div>
|
||||
<datalist id="list-fourchanImageHost"></datalist>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Captcha Language</legend>
|
||||
<div>Choose from <a href="https://developers.google.com/recaptcha/docs/language" target="_blank">list of language codes</a>. Leave blank to autoselect.</div>
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
ImageHost =
|
||||
init: ->
|
||||
return unless (@useFaster = Conf['Use Faster Image Host']) and g.VIEW in ['index', 'thread']
|
||||
return unless (@useFaster = /\S/.test(Conf['fourchanImageHost'])) and g.SITE.software is 'yotsuba' and g.VIEW in ['index', 'thread']
|
||||
Callbacks.Post.push
|
||||
name: 'Image Host Rewriting'
|
||||
cb: @node
|
||||
|
||||
suggestions: ['i.4cdn.org', 'is2.4chan.org']
|
||||
|
||||
host: ->
|
||||
'i.4cdn.org'
|
||||
Conf['fourchanImageHost'].trim() or 'i.4cdn.org'
|
||||
flashHost: ->
|
||||
'i.4cdn.org'
|
||||
thumbHost: ->
|
||||
@ -19,13 +21,14 @@ ImageHost =
|
||||
node: ->
|
||||
return if @isClone
|
||||
host = ImageHost.host()
|
||||
if @file and ImageHost.regex.test(@file.url.split('/')[2])
|
||||
if @file and ImageHost.test(@file.url.split('/')[2]) and not /\.swf$/.test(@file.url)
|
||||
@file.link.hostname = host
|
||||
@file.thumbLink.hostname = host if @file.thumbLink
|
||||
@file.url = @file.link.href
|
||||
ImageHost.fixLinks $$('a', @nodes.comment)
|
||||
|
||||
fixLinks: (links) ->
|
||||
for link in links when ImageHost.regex.test(link.hostname)
|
||||
link.hostname = ImageHost.host()
|
||||
for link in links when ImageHost.test(link.hostname) and not /\.swf$/.test(link.pathname)
|
||||
host = ImageHost.host()
|
||||
link.hostname = host unless link.hostname is host
|
||||
return
|
||||
|
||||
@ -16,6 +16,7 @@ Linkify =
|
||||
return unless Linkify.regString.test @info.comment
|
||||
for link in $$ 'a', @nodes.comment when ImageHost.test(link.hostname) or /\bnofollow\b/.test(link.rel)
|
||||
$.addClass link, 'linkify'
|
||||
ImageHost.fixLinks [link] if ImageHost.useFaster
|
||||
Embedding.process link, @
|
||||
links = Linkify.process @nodes.comment
|
||||
ImageHost.fixLinks links if ImageHost.useFaster
|
||||
|
||||
@ -304,10 +304,6 @@ Config =
|
||||
true
|
||||
'Apply <%= meta.name %> mute and volume settings to videos opened in their own tabs.'
|
||||
]
|
||||
'Use Faster Image Host': [
|
||||
true
|
||||
'Change is*.4chan.org links to point to the faster i.4cdn.org host.'
|
||||
]
|
||||
|
||||
'Menu':
|
||||
'Menu': [
|
||||
@ -1164,3 +1160,5 @@ Config =
|
||||
'https://api.captcha.guru': ''
|
||||
'https://2captcha.com': ''
|
||||
}]
|
||||
|
||||
fourchanImageHost: 'i.4cdn.org'
|
||||
|
||||
@ -76,6 +76,7 @@ Main =
|
||||
Conf['Bottom QR Link'] = true
|
||||
Conf['Toggleable Thread Watcher'] = true
|
||||
Conf['siteSoftware'] = ''
|
||||
Conf['Use Faster Image Host'] = 'true'
|
||||
|
||||
# Enforce JS whitelist
|
||||
if /\.4chan(?:nel)?\.org$/.test(location.hostname) and !$$('script:not([src])', d).filter((s) -> /this\[/.test(s.textContent)).length
|
||||
|
||||
@ -6,7 +6,6 @@ SW.tinyboard =
|
||||
'Board Configuration'
|
||||
'Normalize URL'
|
||||
'Captcha Configuration'
|
||||
'Image Host Rewriting'
|
||||
'Index Generator'
|
||||
'Announcement Hiding'
|
||||
'Resurrect Quotes'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user