2018-10-08 19:30:22 +00:00
|
|
|
/* global page */
|
|
|
|
|
|
|
|
page.prepareShareX = function () {
|
2018-12-18 17:01:28 +00:00
|
|
|
if (!page.token) return
|
2018-10-09 19:52:41 +00:00
|
|
|
const origin = (location.hostname + location.pathname).replace(/\/(dashboard)?$/, '')
|
|
|
|
const originClean = origin.replace(/\//g, '_')
|
2019-08-20 02:16:34 +00:00
|
|
|
const sharexElement = document.querySelector('#ShareX')
|
2018-10-09 19:52:41 +00:00
|
|
|
const sharexFile = `{
|
|
|
|
"Name": "${originClean}",
|
|
|
|
"DestinationType": "ImageUploader, FileUploader",
|
|
|
|
"RequestType": "POST",
|
|
|
|
"RequestURL": "${location.protocol}//${origin}/api/upload",
|
|
|
|
"FileFormName": "files[]",
|
|
|
|
"Headers": {
|
|
|
|
"token": "${page.token}"
|
|
|
|
},
|
|
|
|
"ResponseType": "Text",
|
|
|
|
"URL": "$json:files[0].url$",
|
|
|
|
"ThumbnailURL": "$json:files[0].url$"
|
|
|
|
}\n`
|
|
|
|
const sharexBlob = new Blob([sharexFile], { type: 'application/octet-binary' })
|
2018-10-08 19:30:22 +00:00
|
|
|
sharexElement.setAttribute('href', URL.createObjectURL(sharexBlob))
|
2018-10-09 19:52:41 +00:00
|
|
|
sharexElement.setAttribute('download', `${originClean}.sxcu`)
|
2018-10-08 19:30:22 +00:00
|
|
|
}
|