Last active
December 12, 2016 15:36
-
-
Save tomayac/b9d5f17df132f0e7edeaaac7ef0b887d to your computer and use it in GitHub Desktop.
Doodle Bookmarklet Wizard for Weekly Recurring Events
This file contains hidden or 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: (() => { | |
// Whenever you run the bookmarklet, always returns the next Wednesday. | |
const nextWednesday = () => { | |
let ret = new Date(); | |
ret.setDate(ret.getDate() + (3 - 1 - ret.getDay() + 7) % 7 + 1); | |
return ret.toLocaleDateString('en-US', { | |
weekday: 'long', | |
year: 'numeric', | |
month: 'long', | |
day: 'numeric' | |
}); | |
}; | |
// As a running gag participants can choose between soccer (i.e., come that | |
// day) or a random emoji (i.e., not come that day). More emoji => More fun. | |
const emojis = 'ππ¬πππππ ππππππβΊοΈπππππ' | |
.split(/([\uD800-\uDBFF][\uDC00-\uDFFF])/).filter(a => a.length > 1); | |
// See https://goo.gl/u3ETG9 for all options, for undocumented options | |
// inspect Doodle's HTML | |
const options = { | |
type: 'text', | |
levels: 2, | |
locale: 'en', | |
title: 'Soccer on ' + nextWednesday(), | |
location: 'Indoor soccer hall', | |
description: 'Weekly company soccer match', | |
name: 'John Doe', | |
eMailAddress: '[email protected]', | |
option1: 'β½οΈ Β Soccer', | |
option2: `${emojis[~~(Math.random() * emojis.length) + 1]}Β Alternative`, | |
hidden: false, | |
columnConstraint: 15, | |
rowConstraint: 1, | |
invitees: ['[email protected]'] | |
}; | |
// Use HTTP POST so we can pass email addresses and a _blank target so that | |
// the bookmarklet opens in a new tab. | |
const form = document.createElement('form'); | |
form.method = 'post'; | |
form.action = 'https://doodle.com/create/'; | |
form.target = '_blank'; | |
const node = document.createElement('input'); | |
for (name in options) { | |
node.name = name; | |
node.value = options[name].toString(); | |
form.appendChild(node.cloneNode()); | |
} | |
document.body.appendChild(form); | |
form.submit(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
May not work when opened on sites with Content Security Policy (CSP, like this very site where the Gist is hosted). The error message then isβ¦
Refused to send form data to 'https://doodle.com/create/' because it violates the following Content Security Policy directive: "form-action 'self' github.com gist.github.com".