"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']?
|
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(/^(#?\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')
|
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
|
changes
|
||||||
|
|
||||||
loadSettings: (data, cb) ->
|
loadSettings: (data, cb) ->
|
||||||
@ -559,7 +562,7 @@ Settings =
|
|||||||
$.id('lastarchivecheck').textContent = 'never'
|
$.id('lastarchivecheck').textContent = 'never'
|
||||||
|
|
||||||
items = {}
|
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]
|
items[name] = Conf[name]
|
||||||
input = inputs[name]
|
input = inputs[name]
|
||||||
event = if name in ['archiveLists', 'archiveAutoUpdate', 'QR.personas', 'favicon', 'usercss'] then 'change' else 'input'
|
event = if name in ['archiveLists', 'archiveAutoUpdate', 'QR.personas', 'favicon', 'usercss'] then 'change' else 'input'
|
||||||
@ -575,6 +578,10 @@ Settings =
|
|||||||
Settings[key].call input
|
Settings[key].call input
|
||||||
return
|
return
|
||||||
|
|
||||||
|
listImageHost = $.id 'list-fourchanImageHost'
|
||||||
|
for textContent in ImageHost.suggestions
|
||||||
|
$.add listImageHost, $.el 'option', {textContent}
|
||||||
|
|
||||||
$.on inputs['captchaServiceKey'], 'input', Settings.captchaServiceKey
|
$.on inputs['captchaServiceKey'], 'input', Settings.captchaServiceKey
|
||||||
$.get 'captchaServiceKey', Conf['captchaServiceKey'], ({captchaServiceKey}) ->
|
$.get 'captchaServiceKey', Conf['captchaServiceKey'], ({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>
|
<button id="update-archives">Update now</button> Last updated: <time id="lastarchivecheck"></time> <label><input type="checkbox" name="archiveAutoUpdate"> Auto-update</label>
|
||||||
</fieldset>
|
</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>
|
<fieldset>
|
||||||
<legend>Captcha Language</legend>
|
<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>
|
<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 =
|
ImageHost =
|
||||||
init: ->
|
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
|
Callbacks.Post.push
|
||||||
name: 'Image Host Rewriting'
|
name: 'Image Host Rewriting'
|
||||||
cb: @node
|
cb: @node
|
||||||
|
|
||||||
|
suggestions: ['i.4cdn.org', 'is2.4chan.org']
|
||||||
|
|
||||||
host: ->
|
host: ->
|
||||||
'i.4cdn.org'
|
Conf['fourchanImageHost'].trim() or 'i.4cdn.org'
|
||||||
flashHost: ->
|
flashHost: ->
|
||||||
'i.4cdn.org'
|
'i.4cdn.org'
|
||||||
thumbHost: ->
|
thumbHost: ->
|
||||||
@ -19,13 +21,14 @@ ImageHost =
|
|||||||
node: ->
|
node: ->
|
||||||
return if @isClone
|
return if @isClone
|
||||||
host = ImageHost.host()
|
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.link.hostname = host
|
||||||
@file.thumbLink.hostname = host if @file.thumbLink
|
@file.thumbLink.hostname = host if @file.thumbLink
|
||||||
@file.url = @file.link.href
|
@file.url = @file.link.href
|
||||||
ImageHost.fixLinks $$('a', @nodes.comment)
|
ImageHost.fixLinks $$('a', @nodes.comment)
|
||||||
|
|
||||||
fixLinks: (links) ->
|
fixLinks: (links) ->
|
||||||
for link in links when ImageHost.regex.test(link.hostname)
|
for link in links when ImageHost.test(link.hostname) and not /\.swf$/.test(link.pathname)
|
||||||
link.hostname = ImageHost.host()
|
host = ImageHost.host()
|
||||||
|
link.hostname = host unless link.hostname is host
|
||||||
return
|
return
|
||||||
|
|||||||
@ -16,6 +16,7 @@ Linkify =
|
|||||||
return unless Linkify.regString.test @info.comment
|
return unless Linkify.regString.test @info.comment
|
||||||
for link in $$ 'a', @nodes.comment when ImageHost.test(link.hostname) or /\bnofollow\b/.test(link.rel)
|
for link in $$ 'a', @nodes.comment when ImageHost.test(link.hostname) or /\bnofollow\b/.test(link.rel)
|
||||||
$.addClass link, 'linkify'
|
$.addClass link, 'linkify'
|
||||||
|
ImageHost.fixLinks [link] if ImageHost.useFaster
|
||||||
Embedding.process link, @
|
Embedding.process link, @
|
||||||
links = Linkify.process @nodes.comment
|
links = Linkify.process @nodes.comment
|
||||||
ImageHost.fixLinks links if ImageHost.useFaster
|
ImageHost.fixLinks links if ImageHost.useFaster
|
||||||
|
|||||||
@ -304,10 +304,6 @@ Config =
|
|||||||
true
|
true
|
||||||
'Apply <%= meta.name %> mute and volume settings to videos opened in their own tabs.'
|
'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':
|
||||||
'Menu': [
|
'Menu': [
|
||||||
@ -1164,3 +1160,5 @@ Config =
|
|||||||
'https://api.captcha.guru': ''
|
'https://api.captcha.guru': ''
|
||||||
'https://2captcha.com': ''
|
'https://2captcha.com': ''
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
fourchanImageHost: 'i.4cdn.org'
|
||||||
|
|||||||
@ -76,6 +76,7 @@ Main =
|
|||||||
Conf['Bottom QR Link'] = true
|
Conf['Bottom QR Link'] = true
|
||||||
Conf['Toggleable Thread Watcher'] = true
|
Conf['Toggleable Thread Watcher'] = true
|
||||||
Conf['siteSoftware'] = ''
|
Conf['siteSoftware'] = ''
|
||||||
|
Conf['Use Faster Image Host'] = 'true'
|
||||||
|
|
||||||
# Enforce JS whitelist
|
# Enforce JS whitelist
|
||||||
if /\.4chan(?:nel)?\.org$/.test(location.hostname) and !$$('script:not([src])', d).filter((s) -> /this\[/.test(s.textContent)).length
|
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'
|
'Board Configuration'
|
||||||
'Normalize URL'
|
'Normalize URL'
|
||||||
'Captcha Configuration'
|
'Captcha Configuration'
|
||||||
'Image Host Rewriting'
|
|
||||||
'Index Generator'
|
'Index Generator'
|
||||||
'Announcement Hiding'
|
'Announcement Hiding'
|
||||||
'Resurrect Quotes'
|
'Resurrect Quotes'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user