-
Notifications
You must be signed in to change notification settings - Fork 1
/
popup.js
31 lines (24 loc) · 936 Bytes
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import * as mdc from "material-components-web"
import './node_modules/material-components-web/dist/material-components-web.css'
mdc.autoInit()
mdc.ripple.MDCRipple.attachTo(document.querySelector('.mdc-button'))
const markdownLinkText = document.getElementById('js-markdown-link-text')
chrome.tabs.getSelected(null, (tab) =>{
markdownLinkText.value = `[${tab.title}](${tab.url})`
markdownLinkText.select()
})
const copyButton = document.getElementById('js-copy-button')
copyButton.addEventListener('click', () => {
markdownLinkText.select()
document.execCommand('copy')
window.getSelection().removeAllRanges()
new Promise((resolve, reject) => {
setTimeout(() => resolve(), 100)
}).then(() => {
copyButton.disabled = true
copyButton.innerText = 'COPY DONE!'
})
new Promise((resolve, reject) => {
setTimeout(() => resolve(), 1200)
}).then(() => window.close())
})