Merge branch 'next'

This commit is contained in:
ccd0 2016-07-06 13:16:50 -07:00
commit 497dbe9b13
9 changed files with 42 additions and 14 deletions

View File

@ -393,6 +393,9 @@ Settings =
if compareString < '00001.00012.00000.00006'
if data['sauces']?
set 'sauces', data['sauces'].replace(/^(#?\s*)https:\/\/(?:desustorage|cuckchan)\.org\//mg, '$1https://desuarchive.org/')
if compareString < '00001.00012.00001.00000'
if not data['Persistent Thread Watcher']? and data['Toggleable Thread Watcher']?
set 'Persistent Thread Watcher', not data['Toggleable Thread Watcher']
changes
loadSettings: (data, cb) ->

View File

@ -97,6 +97,9 @@ Keybinds =
when Conf['Update thread watcher']
return unless ThreadWatcher.enabled
ThreadWatcher.buttonFetchAll()
when Conf['Toggle thread watcher']
return unless ThreadWatcher.enabled
ThreadWatcher.toggleWatcher()
# Images
when Conf['Expand image']
return unless ImageExpand.enabled and threadRoot

View File

@ -34,10 +34,10 @@ ThreadWatcher =
if Conf['Fixed Thread Watcher']
$.addClass doc, 'fixed-watcher'
if Conf['Toggleable Thread Watcher']
if !Conf['Persistent Thread Watcher']
@dialog.hidden = true
Header.addShortcut 'watcher', sc, 510
$.addClass doc, 'toggleable-watcher'
Header.addShortcut 'watcher', sc, 510
ThreadWatcher.fetchAuto()

View File

@ -384,9 +384,9 @@ Config =
'Makes the thread watcher scroll with the page.'
1
]
'Toggleable Thread Watcher': [
true
'Adds a shortcut for the thread watcher and hides the watcher by default.'
'Persistent Thread Watcher': [
false
'The thread watcher will be visible when the page is loaded.'
1
]
'Mark New IPs': [
@ -862,6 +862,10 @@ Config =
'Shift+r'
'Manually refresh thread watcher.'
]
'Toggle thread watcher': [
't'
'Toggle visibility of thread watcher.'
]
# Images
'Expand image': [
'Shift+e'

View File

@ -931,9 +931,6 @@ span.hide-announcement {
#thread-watcher a {
text-decoration: none;
}
:root:not(.toggleable-watcher) #thread-watcher .move > .close {
display: none;
}
#thread-watcher .move > .close {
position: absolute;
right: 0px;

View File

@ -52,6 +52,7 @@ Main =
Conf['Show Name and Subject'] = false
Conf['QR Shortcut'] = true
Conf['Bottom QR Link'] = true
Conf['Toggleable Thread Watcher'] = true
# Pseudo-enforce default whitelist while configuration loads
if $.platform is 'crx' then $.global ->

View File

@ -1,6 +1,24 @@
requestID = 0
chrome.runtime.onMessage.addListener (request, sender, sendResponse) ->
if request.responseType is 'arraybuffer'
# Cross-origin image fetching. Need permission.
chrome.permissions.contains
origins: ['*://*/']
, (result) ->
if result
ajax request, sender, sendResponse
else
chrome.permissions.request
origins: ['*://*/']
, ->
ajax request, sender, sendResponse
return true
else
# JSON fetching from non-HTTPS archive.
ajax request, sender, sendResponse
ajax = (request, sender, sendResponse) ->
id = requestID
requestID++
sendResponse id
@ -10,11 +28,11 @@ chrome.runtime.onMessage.addListener (request, sender, sendResponse) ->
xhr.responseType = request.responseType
xhr.addEventListener 'load', ->
if @readyState is @DONE && xhr.status is 200
contentType = @getResponseHeader 'Content-Type'
contentDisposition = @getResponseHeader 'Content-Disposition'
{response} = @
if request.responseType is 'arraybuffer'
response = [new Uint8Array(response)...]
contentType = @getResponseHeader 'Content-Type'
contentDisposition = @getResponseHeader 'Content-Disposition'
chrome.tabs.sendMessage sender.tab.id, {id, response, contentType, contentDisposition}
else
chrome.tabs.sendMessage sender.tab.id, {id, error: true}

View File

@ -25,7 +25,9 @@
<% } %> "minimum_chrome_version": "<%= meta.min.chrome %>",
"permissions": [
"storage",
"http://*/",
"https://*/"
"*://a.4cdn.org/"
],
"optional_permissions": [
"*://*/"
]
}

View File

@ -14,7 +14,7 @@ CrossOrigin =
# XXX https://forums.lanik.us/viewtopic.php?f=64&t=24173&p=78310
url = url.replace /^((?:https?:)?\/\/(?:\w+\.)?4c(?:ha|d)n\.org)\/adv\//, '$1//adv/'
<% if (type === 'crx') { %>
if /^https:\/\//.test(url) or location.protocol is 'http:'
if url.split('/')[...3].join('/') is "#{location.protocol}//i.4cdn.org"
xhr = new XMLHttpRequest()
xhr.open 'GET', url, true
xhr.setRequestHeader key, value for key, value of headers