copy image to clipboard #715

This commit is contained in:
cutls 2022-10-10 15:08:57 +09:00
parent dff544c3d2
commit 49c78d2263
10 changed files with 51 additions and 20 deletions

View File

@ -79,6 +79,8 @@ onmessage = function(e) {
ipc.send('sendMarkersComplete', null) ipc.send('sendMarkersComplete', null)
} else if (e.data[0] == 'copy') { } else if (e.data[0] == 'copy') {
ipc.send('copy', e.data[1]) ipc.send('copy', e.data[1])
} else if (e.data[0] == 'copyBinary') {
ipc.send('copyBinary', e.data[1])
} else if (e.data[0] == 'log') { } else if (e.data[0] == 'log') {
ipc.send('log', e.data[1]) ipc.send('log', e.data[1])
} else if (e.data[0] == 'twitterLogin') { } else if (e.data[0] == 'twitterLogin') {

View File

@ -78,7 +78,7 @@ function imgCont(type) {
function imageXhr(id, key, murl) { function imageXhr(id, key, murl) {
let time = 0 let time = 0
var startTime = new Date() var startTime = new Date()
const timer = setInterval(function() { const timer = setInterval(function () {
time = time + 1 time = time + 1
$('#imgsec').text(time) $('#imgsec').text(time)
}, 10) }, 10)
@ -343,3 +343,13 @@ function copyImgUrl() {
execCopy(murl) execCopy(murl)
M.toast({ html: lang.lang_img_copyDone, displayLength: 1500 }) M.toast({ html: lang.lang_img_copyDone, displayLength: 1500 })
} }
async function copyImgBinary() {
var murl = $('#imagemodal').attr('data-original')
const blob = await (await fetch(murl)).blob()
const reader = new FileReader()
reader.onloadend = function () {
postMessage(['copyBinary', reader.result], '*')
M.toast({ html: lang.lang_imgBin_copyDone, displayLength: 1500 })
}
reader.readAsDataURL(blob)
}

View File

@ -7,6 +7,7 @@ function system(mainWindow, dir, lang, dirname) {
var JSON5 = require('json5') var JSON5 = require('json5')
var ipc = electron.ipcMain var ipc = electron.ipcMain
const clipboard = electron.clipboard const clipboard = electron.clipboard
const nativeImage = electron.nativeImage
var tmp_img = join(app.getPath('userData'), 'tmp.png') var tmp_img = join(app.getPath('userData'), 'tmp.png')
var ha_path = join(app.getPath('userData'), 'hardwareAcceleration') var ha_path = join(app.getPath('userData'), 'hardwareAcceleration')
var wv_path = join(app.getPath('userData'), 'webview') var wv_path = join(app.getPath('userData'), 'webview')
@ -255,6 +256,10 @@ function system(mainWindow, dir, lang, dirname) {
ipc.on('copy', (e, arg) => { ipc.on('copy', (e, arg) => {
clipboard.writeText(arg) clipboard.writeText(arg)
}) })
ipc.on('copyBinary', (e, arg) => {
const ni = nativeImage.createFromDataURL(arg)
clipboard.writeImage(ni)
})
//ログ //ログ
ipc.on('log', (e, arg) => { ipc.on('log', (e, arg) => {
var today = new Date() var today = new Date()

View File

@ -14,6 +14,7 @@
<span id="imgprog"></span>% <br /> <span id="imgprog"></span>% <br />
<span id="imgsec"></span>ms <br /><span id="imgbyte"></span>KB <span id="imgsec"></span>ms <br /><span id="imgbyte"></span>KB
</div> </div>
<span style="padding: 0.6rem" class="btnsgroup">
<a class="waves-effect white-text" onclick="zoom(2)"> <a class="waves-effect white-text" onclick="zoom(2)">
<i class="material-icons">zoom_in</i> <i class="material-icons">zoom_in</i>
</a> </a>
@ -23,9 +24,16 @@
<a class="waves-effect white-text" onclick="rotate(false)"> <a class="waves-effect white-text" onclick="rotate(false)">
<i class="material-icons">rotate_90_degrees_ccw</i> <i class="material-icons">rotate_90_degrees_ccw</i>
</a> </a>
<button class="btn waves-effect blue" onclick="copyImgUrl()" title="@@copyURL@@"> </span>
<span style="padding: 0.6rem" class="btnsgroup">
<span style="position: relative; top: -2px;">Copy:</span>
<a class="waves-effect white-text" onclick="copyImgBinary()" title="@@copyBinary@@">
<i class="material-icons">image</i>
</a>
<a class="waves-effect white-text" onclick="copyImgUrl()" title="@@copyURL@@">
<i class="material-icons">link</i> <i class="material-icons">link</i>
</button> </a>
</span>
<button class="btn waves-effect purple" onclick="dlImg()"> <button class="btn waves-effect purple" onclick="dlImg()">
<i class="material-icons">file_download</i> <i class="material-icons">file_download</i>
</button> </button>

View File

@ -73,6 +73,7 @@
"favRegist": "Favourite", "favRegist": "Favourite",
"openBrowser": "Open in browser", "openBrowser": "Open in browser",
"screenshot": "Take a screenshot", "screenshot": "Take a screenshot",
"copyBinary": "Copy raw image",
"copyURL": "Copy the URL", "copyURL": "Copy the URL",
"copy": "Copy", "copy": "Copy",
"embed": "Embed", "embed": "Embed",

View File

@ -127,6 +127,7 @@
"lang_tl_postmarkers_title": "Process...", "lang_tl_postmarkers_title": "Process...",
"lang_tl_postmarkers": "POST markers data. Please wait", "lang_tl_postmarkers": "POST markers data. Please wait",
"lang_img_DLDone": "Downloaded:", "lang_img_DLDone": "Downloaded:",
"lang_imgBin_copyDone": "Copied: raw data of this image",
"lang_img_copyDone": "Copied: URL of this image", "lang_img_copyDone": "Copied: URL of this image",
"lang_layout_gotop": "Go top of this column. When icon is red, this column cannot connect straming API. Please reload.", "lang_layout_gotop": "Go top of this column. When icon is red, this column cannot connect straming API. Please reload.",
"lang_layout_thisacct": "{{notf}} of this account", "lang_layout_thisacct": "{{notf}} of this account",

View File

@ -71,6 +71,7 @@
"favRegist": "お気に入り", "favRegist": "お気に入り",
"openBrowser": "ブラウザで開く", "openBrowser": "ブラウザで開く",
"screenshot": "スクリーンショット", "screenshot": "スクリーンショット",
"copyBinary": "画像をコピー",
"copyURL": "URLをコピー", "copyURL": "URLをコピー",
"copy": "コピー", "copy": "コピー",
"embed": "埋め込む", "embed": "埋め込む",

View File

@ -126,6 +126,7 @@
"lang_tl_postmarkers_title": "処理中", "lang_tl_postmarkers_title": "処理中",
"lang_tl_postmarkers": "未読マーカー送信してるしちょっと待ってな…", "lang_tl_postmarkers": "未読マーカー送信してるしちょっと待ってな…",
"lang_img_DLDone": "ダウンロード先:", "lang_img_DLDone": "ダウンロード先:",
"lang_imgBin_copyDone": "画像データをコピーしたで。",
"lang_img_copyDone": "画像のURLをコピーしたで", "lang_img_copyDone": "画像のURLをコピーしたで",
"lang_layout_gotop": "一番上へ。アイコンが赤のときはストリーミングに接続できてへんしF5で再読込やってみて。", "lang_layout_gotop": "一番上へ。アイコンが赤のときはストリーミングに接続できてへんしF5で再読込やってみて。",
"lang_layout_thisacct": "このアカウントの{{notf}}", "lang_layout_thisacct": "このアカウントの{{notf}}",

View File

@ -73,6 +73,7 @@
"favRegist": "お気に入り", "favRegist": "お気に入り",
"openBrowser": "ブラウザで開く", "openBrowser": "ブラウザで開く",
"screenshot": "スクリーンショット", "screenshot": "スクリーンショット",
"copyBinary": "画像をコピー",
"copyURL": "URLをコピー", "copyURL": "URLをコピー",
"copy": "コピー", "copy": "コピー",
"embed": "埋め込む", "embed": "埋め込む",

View File

@ -128,6 +128,7 @@
"lang_tl_postmarkers_title": "処理中", "lang_tl_postmarkers_title": "処理中",
"lang_tl_postmarkers": "未読マーカーを送信しています。3秒以内に閉じられます。", "lang_tl_postmarkers": "未読マーカーを送信しています。3秒以内に閉じられます。",
"lang_img_DLDone": "ダウンロード先:", "lang_img_DLDone": "ダウンロード先:",
"lang_imgBin_copyDone": "画像データをコピーしました。",
"lang_img_copyDone": "画像のURLをコピーしました。", "lang_img_copyDone": "画像のURLをコピーしました。",
"lang_layout_gotop": "一番上へ。アイコンが赤のときはストリーミングに接続できていません。F5等で再読込をお試し下さい。", "lang_layout_gotop": "一番上へ。アイコンが赤のときはストリーミングに接続できていません。F5等で再読込をお試し下さい。",
"lang_layout_thisacct": "このアカウントの{{notf}}", "lang_layout_thisacct": "このアカウントの{{notf}}",