Copy instead of prompting data link for Chromium based browsers
This commit is contained in:
parent
43c63db954
commit
806cc35d17
3 changed files with 25 additions and 23 deletions
|
@ -2366,25 +2366,9 @@ body.toHook .done .channels .selectOptions .hook {
|
|||
|
||||
/* Send button and components **/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.invisible {
|
||||
display: none!important;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 7px;
|
||||
|
|
|
@ -64,7 +64,6 @@ var params = currentURL().searchParams,
|
|||
if (autoParams) isReversed ? urlOptions({ set: ['reverse', ''] }) : urlOptions({ remove: 'reverse' });
|
||||
},
|
||||
urlOptions = ({ remove, set }) => {
|
||||
console.log(remove, set);
|
||||
const url = currentURL();
|
||||
if (remove) url.searchParams.delete(remove);
|
||||
if (set) url.searchParams.set(set[0], set[1]);
|
||||
|
@ -970,8 +969,26 @@ addEventListener('DOMContentLoaded', () => {
|
|||
})
|
||||
|
||||
document.querySelector('.top-btn.menu')?.addEventListener('click', e => {
|
||||
if (e.target.closest('.item.dataLink'))
|
||||
return prompt('Here\'s the current URL with base64 embed data:', jsonToBase64(json, true));
|
||||
if (e.target.closest('.item.dataLink')) {
|
||||
const data = jsonToBase64(json, true);
|
||||
// With long text inside a 'prompt' on Chromium based browsers, some text will but cut and replaced with '...'.
|
||||
// So, for the Chromium users, we copy to clipboard instead of showing a prompt.
|
||||
if (!window.chrome)
|
||||
return prompt('Here\'s the current URL with base64 embed data:', data);
|
||||
if (location.protocol === 'http:')
|
||||
// Clipboard API only works on HTTPS protocol.
|
||||
navigator.clipboard.writeText(data);
|
||||
else {
|
||||
const input = document.createElement('input');
|
||||
input.value = data;
|
||||
document.body.appendChild(input);
|
||||
input.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(input);
|
||||
}
|
||||
|
||||
alert('Copied to clipboard.');
|
||||
}
|
||||
|
||||
const input = e.target.closest('.item')?.querySelector('input');
|
||||
if (input) input.checked = !input.checked;
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
<div>Get data link</div>
|
||||
<div>Get URL with data link</div>
|
||||
</div>
|
||||
<div class="item normal auto no-frame">
|
||||
<!-- <input type="checkbox" id="auto" name="auto" autocomplete="off" class="hidden"> -->
|
||||
|
@ -334,5 +334,6 @@
|
|||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<input type="hidden" value>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Reference in a new issue