Last active
November 5, 2020 12:41
-
-
Save mefjuu/b0ea325305ab026e73b68285d1474b0b to your computer and use it in GitHub Desktop.
App Store bookmarklet for copy-paste an app's "What's new" and "Promotional Text" between languages / versions
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:(function copyFromCurrentLanguage(){ | |
| if (!document.hasFocus()) { | |
| window.alert("Click the document body first"); | |
| return; | |
| } | |
| const promotionalText = document.querySelector("#promotionalText").innerText; | |
| const whatsNew = document.querySelector("#whatsNew").innerText; | |
| const data = { | |
| promotionalText, | |
| whatsNew | |
| }; | |
| navigator.clipboard.writeText(JSON.stringify(data)).then(() => { | |
| window.alert("Copied!\n\nWhat's new:\n" + whatsNew + "\n\nPromotional text:\n" + promotionalText); | |
| }) | |
| }()) | |
| // One-liner to paste as a bookmark URL | |
| javascript:(function copyFromCurrentLanguage(){ if (!document.hasFocus()) { window.alert("Click the document body first"); return; } const promotionalText = document.querySelector("#promotionalText").innerText; const whatsNew = document.querySelector("#whatsNew").innerText; const data = { promotionalText, whatsNew }; navigator.clipboard.writeText(JSON.stringify(data)).then(() => { window.alert("Copied!\n\nWhat's new:\n" + whatsNew + "\n\nPromotional text:\n" + promotionalText); }) }()) | |
| javascript:(function pasteToCurrentLanguage(){ | |
| navigator.clipboard.readText().then((value) => { | |
| const data = JSON.parse(value); | |
| if (data.promotionalText) { | |
| const el = document.querySelector("#promotionalText"); | |
| el.innerText = data.promotionalText; | |
| el.dispatchEvent(new Event('input')); | |
| } | |
| if (data.whatsNew) { | |
| const el = document.querySelector("#whatsNew"); | |
| el.innerText = data.whatsNew; | |
| el.dispatchEvent(new Event('input')); | |
| } | |
| }); | |
| }()) | |
| // And one-liner... | |
| javascript:(function pasteToCurrentLanguage(){ navigator.clipboard.readText().then((value) => { const data = JSON.parse(value); if (data.promotionalText) { const el = document.querySelector("#promotionalText"); el.innerText = data.promotionalText; el.dispatchEvent(new Event('input')); } if (data.whatsNew) { const el = document.querySelector("#whatsNew"); el.innerText = data.whatsNew; el.dispatchEvent(new Event('input')); } }); }()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment