Last active
March 30, 2023 10:37
-
-
Save heguro/ea74fc2677aa96244e1404af01c47d91 to your computer and use it in GitHub Desktop.
nosaray-copy-all-ids-bookmarklet (unofficial, temporary)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript:(()=>{const e=document.createElement("button");Object.assign(e.style,{position:"fixed",top:"0",left:"0",width:"20rem",height:"2rem"}),e.innerText="<< click to copy all IDs! >>",e.onclick=()=>{const o=[],t=window.prompt,n=document.execCommand;window.prompt=(e,t)=>{o.push(t)},document.execCommand=void 0;const c=[...document.querySelectorAll("[aria-label='copy note id']")];for(const e of c)e.click();window.prompt=t,document.execCommand=n;const m=document.createElement("textarea");m.value=o.join("\n"),document.body.append(m),m.select(),document.execCommand("copy"),m.remove(),e.remove()},document.body.append(e)})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // use in devtools console. | |
| // temporary code before offically launching the copy all feature | |
| // license: public domain | |
| (() => { | |
| const newButton = document.createElement('button'); | |
| Object.assign(newButton.style, { | |
| position: 'fixed', | |
| top: '0', | |
| left: '0', | |
| width: '20rem', | |
| height: '2rem', | |
| }); | |
| newButton.innerText = '<< click to copy all IDs! >>'; | |
| newButton.onclick = () => { | |
| const noteIds = []; | |
| // temporary overwrite window.prompt and document.execCommand | |
| // If document.execCommand cannot be used to copy, ChakraUI will fall back to window.prompt | |
| const defaultPrompt = window.prompt; | |
| const defaultExecCommand = document.execCommand; | |
| window.prompt = (t1, t2) => { | |
| noteIds.push(t2); | |
| } | |
| document.execCommand = undefined; | |
| // click all copy buttons | |
| const buttons = [...document.querySelectorAll("[aria-label='copy note id']")]; | |
| for (const button of buttons) { | |
| button.click(); | |
| } | |
| // all noteIDs saved | |
| // console.log(noteIds); | |
| // restore overwritten functions | |
| window.prompt = defaultPrompt; | |
| document.execCommand = defaultExecCommand; | |
| // copy saved IDs to clipboard | |
| const textarea = document.createElement('textarea'); | |
| textarea.value = noteIds.join('\n'); | |
| document.body.append(textarea); | |
| textarea.select(); | |
| document.execCommand('copy'); | |
| textarea.remove(); | |
| // remove this line to persist | |
| newButton.remove(); | |
| }; | |
| document.body.append(newButton); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment