Skip to content

Instantly share code, notes, and snippets.

@azu
Last active March 2, 2019 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azu/b79503ee65fb55ce5055441bc768d93f to your computer and use it in GitHub Desktop.
Save azu/b79503ee65fb55ce5055441bc768d93f to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name irodr:post-tweet
// @namespace info.efcl
// @include https://irodr.netlify.com/
// @include http://localhost:13245/
// @version 1
// @grant none
// @run-at document-end
// ==/UserScript==
window.addEventListener("keydown", (event) => {
if(event.shiftKey && event.metaKey && event.key == "Enter") {
const item = window.userScript.getActiveContent();
const subscription = window.userScript.getActiveSubscription();
if(!item || !subscription){
return;
}
event.preventDefault();
const selectedText = window.getSelection().toString();
const title = subscription.title ? `${item.title} - ${subscription.title}` : item.title;
location.href = `post-tweet://?url=${encodeURIComponent(item.url)}&title=${encodeURIComponent(title)}&quote=${encodeURIComponent(selectedText)}`
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment