adding to gitea repo
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
// ==UserScript==
|
||||
// @name ClipHTMLEdit
|
||||
// @namespace Violentmonkey Scripts
|
||||
// @version 1.0
|
||||
// @author -
|
||||
// @grant GM.setClipboard
|
||||
// @grant GM.getClipboard
|
||||
// @description 6/18/2024, 12:25:28 PM
|
||||
// @match https://wiki.gianluccapirovano.com/*
|
||||
// @require https://cdn.jsdelivr.net/npm/@violentmonkey/shortcut@1
|
||||
// ==/UserScript==
|
||||
var mariohtml
|
||||
navigator.clipboard.read()
|
||||
|
||||
|
||||
VM.shortcut.register('a-1', () => {
|
||||
var htmltext = prompt("What do you want to copy as html?", mariohtml)
|
||||
GM.setClipboard(htmltext, 'text/html')
|
||||
});
|
||||
|
||||
|
||||
VM.shortcut.register('a-2', async () => {
|
||||
const clipboardContents = await navigator.clipboard.read({
|
||||
unsanitized: ["text/html"],
|
||||
});
|
||||
mariohtml = await getHTMLFromClipboardContents(clipboardContents);
|
||||
window.alert(mariohtml)
|
||||
});
|
||||
|
||||
|
||||
async function getHTMLFromClipboardContents(clipboardContents) {
|
||||
for (const item of clipboardContents) {
|
||||
if (item.types.includes("text/html")) {
|
||||
const blob = await item.getType("text/html");
|
||||
const blobText = await blob.text();
|
||||
return blobText;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user