More work on post from url
This commit is contained in:
parent
f0bd6b1b04
commit
d8a168a549
@ -14,6 +14,7 @@
|
|||||||
// @grant GM_setValue
|
// @grant GM_setValue
|
||||||
// @grant GM_deleteValue
|
// @grant GM_deleteValue
|
||||||
// @grant GM_openInTab
|
// @grant GM_openInTab
|
||||||
|
// @grant GM_xmlhttpRequest
|
||||||
// @run-at document-start
|
// @run-at document-start
|
||||||
// @updateURL https://github.com/Spittie/4chan-x/raw/stable/builds/4chan-X.meta.js
|
// @updateURL https://github.com/Spittie/4chan-x/raw/stable/builds/4chan-X.meta.js
|
||||||
// @downloadURL https://github.com/Spittie/4chan-x/raw/stable/builds/4chan-X.user.js
|
// @downloadURL https://github.com/Spittie/4chan-x/raw/stable/builds/4chan-X.user.js
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
BIN
builds/crx.crx
BIN
builds/crx.crx
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -873,7 +873,7 @@ input.field.tripped:not(:hover):not(:focus) {
|
|||||||
min-height: 59px;
|
min-height: 59px;
|
||||||
min-width: 302px;
|
min-width: 302px;
|
||||||
}
|
}
|
||||||
.captcha-input {
|
.captcha-input{
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 1px 0 0;
|
margin: 1px 0 0;
|
||||||
}
|
}
|
||||||
@ -950,7 +950,7 @@ input#qr-filename:not(.edit) {
|
|||||||
right: 0px;
|
right: 0px;
|
||||||
}
|
}
|
||||||
#qr-filerm {
|
#qr-filerm {
|
||||||
margin-right: 2px;
|
margin-right: 3px;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
#file-n-submit {
|
#file-n-submit {
|
||||||
|
|||||||
@ -22,13 +22,14 @@
|
|||||||
<div id=dump-list></div>
|
<div id=dump-list></div>
|
||||||
<a id=add-post href=javascript:; title="Add a post" tabindex=50>+</a>
|
<a id=add-post href=javascript:; title="Add a post" tabindex=50>+</a>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div id=file-n-submit>
|
<div id=file-n-submit>
|
||||||
<span id=qr-filename-container class=field tabindex=60>
|
<span id=qr-filename-container class=field tabindex=60>
|
||||||
<span id=qr-no-file>No selected file</span>
|
<span id=qr-no-file>No selected file</span>
|
||||||
<input id="qr-filename" data-name="filename" spellcheck="false">
|
<input id="qr-filename" data-name="filename" spellcheck="false">
|
||||||
<span id=qr-extras-container>
|
<span id=qr-extras-container>
|
||||||
<a id=qr-filerm href=javascript:; title='Remove file'>×</a>
|
<a id=qr-filerm href=javascript:; title='Remove file'>×</a>
|
||||||
<a id=url-button title='Post from url'>!</a>
|
<a id=url-button title='Post from url'><i class="fa fa-link"></i></a>
|
||||||
<a id=dump-button title='Dump list'>+</a>
|
<a id=dump-button title='Dump list'>+</a>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
// @grant GM_setValue
|
// @grant GM_setValue
|
||||||
// @grant GM_deleteValue
|
// @grant GM_deleteValue
|
||||||
// @grant GM_openInTab
|
// @grant GM_openInTab
|
||||||
|
// @grant GM_xmlhttpRequest
|
||||||
// @run-at document-start
|
// @run-at document-start
|
||||||
// @updateURL <%= meta.repo %>raw/stable/builds/<%= meta.files.metajs %>
|
// @updateURL <%= meta.repo %>raw/stable/builds/<%= meta.files.metajs %>
|
||||||
// @downloadURL <%= meta.repo %>raw/stable/builds/<%= meta.files.userjs %>
|
// @downloadURL <%= meta.repo %>raw/stable/builds/<%= meta.files.userjs %>
|
||||||
|
|||||||
@ -104,6 +104,7 @@ QR =
|
|||||||
QR.cleanNotifications()
|
QR.cleanNotifications()
|
||||||
d.activeElement.blur()
|
d.activeElement.blur()
|
||||||
$.rmClass QR.nodes.el, 'dump'
|
$.rmClass QR.nodes.el, 'dump'
|
||||||
|
$.rmClass QR.nodes.el, 'url'
|
||||||
unless Conf['Captcha Warning Notifications']
|
unless Conf['Captcha Warning Notifications']
|
||||||
$.rmClass QR.captcha.nodes.input, 'error' if QR.captcha.isEnabled
|
$.rmClass QR.captcha.nodes.input, 'error' if QR.captcha.isEnabled
|
||||||
if Conf['QR Shortcut']
|
if Conf['QR Shortcut']
|
||||||
@ -269,23 +270,46 @@ QR =
|
|||||||
$.addClass QR.nodes.el, 'dump'
|
$.addClass QR.nodes.el, 'dump'
|
||||||
|
|
||||||
handleUrl: ->
|
handleUrl: ->
|
||||||
url = prompt("insert url")
|
<% if (type === 'crx') { %>
|
||||||
|
url = prompt("Insert an url:")
|
||||||
|
return if url == null
|
||||||
|
|
||||||
xhr = new XMLHttpRequest();
|
xhr = new XMLHttpRequest();
|
||||||
xhr.open('GET', url, true)
|
xhr.open('GET', url, true)
|
||||||
xhr.responseType = 'blob'
|
xhr.responseType = 'blob'
|
||||||
|
|
||||||
xhr.onload = (e) ->
|
xhr.onload = (e) ->
|
||||||
if this.readyState == this.DONE && xhr.status == 200
|
if this.readyState == this.DONE && xhr.status == 200
|
||||||
urlBlob = new Blob([this.response], {type: 'image/jpeg'})
|
urlBlob = new Blob([this.response], {type : this.getResponseHeader('content-type')})
|
||||||
|
console.log(urlBlob.type)
|
||||||
|
return if urlBlob.type == null
|
||||||
|
unless urlBlob.type in QR.mimeTypes
|
||||||
|
QR.error "Unsupported file type."
|
||||||
QR.handleFiles([urlBlob])
|
QR.handleFiles([urlBlob])
|
||||||
null
|
return
|
||||||
|
else
|
||||||
|
QR.error "Can't load image."
|
||||||
|
return
|
||||||
|
|
||||||
xhr.onerror = (e) ->
|
xhr.onerror = (e) ->
|
||||||
console.log("error" + e)
|
QR.error "Can't load image."
|
||||||
null
|
return
|
||||||
|
|
||||||
xhr.send()
|
xhr.send()
|
||||||
null
|
return
|
||||||
|
<% } %>
|
||||||
|
<% if (type === 'currently-not-working-userscript') { %>
|
||||||
|
GM_xmlhttpRequest {
|
||||||
|
method: "GET",
|
||||||
|
url: url,
|
||||||
|
responseType: 'blob',
|
||||||
|
onload: (xhr) ->
|
||||||
|
urlBlob = new Blob([xhr.response], {type: 'image/png'})
|
||||||
|
QR.handleFiles([urlBlob])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
|
||||||
handleFiles: (files) ->
|
handleFiles: (files) ->
|
||||||
|
|||||||
@ -157,7 +157,7 @@ QR.post = class
|
|||||||
return
|
return
|
||||||
|
|
||||||
setFile: (@file) ->
|
setFile: (@file) ->
|
||||||
@filename = file.name
|
@filename = file.name || "File from url"
|
||||||
@filesize = $.bytesToString file.size
|
@filesize = $.bytesToString file.size
|
||||||
@nodes.label.hidden = false if QR.spoiler
|
@nodes.label.hidden = false if QR.spoiler
|
||||||
URL.revokeObjectURL @URL
|
URL.revokeObjectURL @URL
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user