Skip to content

Instantly share code, notes, and snippets.

@twilight-sparkle-irl
Last active January 25, 2023 01:22
Show Gist options
  • Save twilight-sparkle-irl/2bed79f36252d9663daab4a4aa80de9c to your computer and use it in GitHub Desktop.
Save twilight-sparkle-irl/2bed79f36252d9663daab4a4aa80de9c to your computer and use it in GitHub Desktop.
Image pasting userscript (click the Raw button with Tampermonkey or etc installed!)
// ==UserScript==
// @name Cohost imagepasting
// @version 0.3.1
// @description paste images in cohost
// @author Twilight
// @match https://cohost.org/*/post/compose*
// @match https://cohost.org/*/post/*/edit
// @icon https://cohost.org/static/a4f72033a674e35d4cc9.png
// @license MIT
// @grant none
// ==/UserScript==
// shoutouts to @lexi and @wowperfect
// https://cohost.org/wowperfect/post/900893-status-of-cohost-pas#comment-91758a87-f2ca-4e01-b0f1-799551721bc4
document.addEventListener('paste', function(e) {
var items = e.clipboardData.items;
for (var i = 0; i < items.length; i++) {
if (items[i].type.indexOf('image') !== -1) {
var blob = items[i].getAsFile();
Object.values(document.querySelector("[title='attach an image']")).filter(x=>!!x.return)[0].return.memoizedProps.onFilesPicked([blob]);
break;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment