Skip to content

Commit

Permalink
fix: key is not writed into the clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed Jul 15, 2019
1 parent beebab9 commit eb73678
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@
"message": "Please click the \"Edit bio\" button or the pencil on the bio box."
},
"automation_request_paste_into_bio_box": {
"message": "Your prove content is write to your clipboard. Please paste into the bio input!"
"message": "Please copy your public key into the bio box and publish it."
},
"automation_request_paste_into_post_box": {
"message": "Prove content has been copied into the clipboard!\nHowever, you need to paste it to the post box by yourself."
"message": "Please copy your public key and publish it to your timeline!"
},
"payload_not_found": {
"message": "Doesn't find payload"
Expand Down
4 changes: 2 additions & 2 deletions src/_locales/zh/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@
"message": "請點擊「編輯簡介」按鈕或簡介旁的鉛筆圖標"
},
"automation_request_paste_into_bio_box": {
"message": "已將公鑰拷貝至剪貼板,可以直接粘貼到輸入框"
"message": "請拷貝公鑰,然後發佈到個人簡介上"
},
"automation_request_paste_into_post_box": {
"message": "已將公鑰拷貝至剪貼板,可以直接粘貼到輸入框"
"message": "請拷貝公鑰,然後發佈到時間綫上"
},
"payload_not_found": {
"message": "找不到 payload"
Expand Down
12 changes: 0 additions & 12 deletions src/extension/content-script/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,3 @@ import './tasks' // ? AutomatedTabTask Run tasks when invoked by background page

import * as HoloflowsKit from '@holoflows/kit'
Object.assign(window, HoloflowsKit)

// Safari does not have navigator.clipboard
if (!navigator.clipboard) Object.assign(navigator, { clipboard: {} })
navigator.clipboard.writeText = async (data: string) => {
const textArea = document.createElement('textarea')
textArea.value = data
document.body.appendChild(textArea)
textArea.focus()
textArea.select()
document.execCommand('copy')
document.body.removeChild(textArea)
}
5 changes: 1 addition & 4 deletions src/extension/content-script/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ export async function pasteIntoPostBox(text: string, warningText: string) {

function copyFailed() {
console.warn('Text not pasted to the text area')
// navigator.clipboard.writeText(text)
// alert(warningText)
prompt(warningText, text)
}
}
Expand Down Expand Up @@ -134,8 +132,7 @@ export default AutomatedTabTask(
dispatchCustomEvents('input', input.value + text)
} catch {
console.warn('Text not pasted to the text area')
navigator.clipboard.writeText(text)
alert(geti18nString('automation_request_paste_into_bio_box'))
prompt(geti18nString('automation_request_paste_into_bio_box'), text)
}
},
pasteIntoPostBox,
Expand Down

0 comments on commit eb73678

Please sign in to comment.