Forked from brunohq/zapier_webhook_bookmarklet.js
Last active
August 20, 2019 08:24
-
-
Save nikjft/6fc3d7c97839d2fa058f20f95f7c52d4 to your computer and use it in GitHub Desktop.
Bookmarklet to trigger a Zapier Webhook from any web page. Any selected text as well as the page title and URL are passed to Zapier.
This file contains 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() | |
{ | |
var webhookURL = '[your webhook URL from Zapier]'; | |
var selectedText = encodeURIComponent(window.getSelection().toString()); | |
var iframe = document.createElement('iframe'); | |
iframe.name = 'response'; | |
iframe.style.visibility = 'hidden'; | |
document.body.appendChild(iframe); | |
var form = document.createElement('form'); | |
form.style.visibility = 'hidden'; | |
form.method = 'post'; | |
form.action = webhookURL; | |
form.target = 'response'; | |
input_url = document.createElement('input'); | |
input_url.name = 'url'; | |
input_url.value = window.location.href; | |
form.appendChild(input_url); | |
input_title = document.createElement('input'); | |
input_title.name = 'title'; | |
input_title.value = document.title; | |
form.appendChild(input_title); | |
input_clip = document.createElement('input'); | |
input_clip.name = 'clip'; | |
input_clip.value = selectedText; | |
form.appendChild(input_clip); | |
document.body.appendChild(form); | |
form.submit(); | |
window.alert('Clipped ' + document.title); | |
} | |
)(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment