${getFileTypeFromUrl(src) || '未知'}
`
$(`#${namespace('drawer__content')}`).append(img)
}
function getNameFromUrl(url) {
const SPLIT_REGEXP = /\/|\?/
return new URL(url).pathname.split(SPLIT_REGEXP).pop()
}
function getFileTypeFromUrl(url) {
const name = getNameFromUrl(url)
const SPLIT_REGEXP = /\./
const res = name.split(SPLIT_REGEXP)[1]
return res ? res.toUpperCase() : null
}
function downloadImg(url) {
const name = getNameFromUrl(url)
GM_download({
url,
name,
saveAs: true,
onload: () => {
openToast('下载成功')
},
onerror: () => {
openToast('下载失败')
}
})
}
; (function ($) {
initStyles()
createDrawer()
createBtn(
'get-material',
`