Skip to content

Instantly share code, notes, and snippets.

@clemens-tolboom
Last active August 29, 2015 14:07
Show Gist options
  • Save clemens-tolboom/7e15dac5bfb07a729f6e to your computer and use it in GitHub Desktop.
Save clemens-tolboom/7e15dac5bfb07a729f6e to your computer and use it in GitHub Desktop.
Auto tag for DrupalCon Amsterdam2014
// ==UserScript==
// @name www.drupal.org
// @namespace tagAmsterdam2014
// @match https://www.drupal.org/node/*
// @run-at document-end
// @grant none
// ==/UserScript==
// SAVE as tagAmsterdam2014.user.js
// Inspired by https://github.com/webflo/drupalsprint-bookmarklet/blob/gh-pages/index.html
// with the help of @helmo
if (jQuery('.field-name-field-project').find('.field-item').text() == 'Drupal core') {
var tags = jQuery('#edit-taxonomy-vocabulary-9-und').val();
var add_comma = tags.length > 0;
tags = jQuery.map(tags.split(', '), jQuery.trim);
if (jQuery.inArray('Amsterdam2014', tags) === -1) {
if (add_comma) {
jQuery('#edit-taxonomy-vocabulary-9-und').val(jQuery('#edit-taxonomy-vocabulary-9-und').val() + ', Amsterdam2014');
} else {
jQuery('#edit-taxonomy-vocabulary-9-und').val( 'Amsterdam2014');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment