Skip to content

Instantly share code, notes, and snippets.

@tomayac
Last active December 12, 2016 15:36
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 tomayac/b9d5f17df132f0e7edeaaac7ef0b887d to your computer and use it in GitHub Desktop.
Save tomayac/b9d5f17df132f0e7edeaaac7ef0b887d to your computer and use it in GitHub Desktop.
Doodle Bookmarklet Wizard for Weekly Recurring Events
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: 'john.doe@example.com',
option1: '⚽️  Soccer',
option2: `${emojis[~~(Math.random() * emojis.length) + 1]}Β Alternative`,
hidden: false,
columnConstraint: 15,
rowConstraint: 1,
invitees: ['soccer@example.com']
};
// 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();
})();
@tomayac
Copy link
Author

tomayac commented Dec 12, 2016

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment