Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jacks0n/5d2147ec2bd5e69bffce34a5e6951593 to your computer and use it in GitHub Desktop.
Save jacks0n/5d2147ec2bd5e69bffce34a5e6951593 to your computer and use it in GitHub Desktop.
Tampermonkey / Greasemonkey script which removes the `destination=` query parameter from Drupal's contextual links (e.g. edit panel, menu item, block, etc).
// ==UserScript==
// @name Remove Drupal's Contextual Destination Parameters
// @namespace http://jacksonc.com
// @version 1.0
// @description Removes the `?destination=` parameter from Drupal's contextual links.
// @author Jackson Cooper <jackson@jacksonc.com>
// @grant none
// @require https://cdnjs.cloudflare.com/ajax/libs/URI.js/1.18.4/URI.min.js
// ==/UserScript==
(function($) {
'use strict';
// List of selectors containing Drupal links that
// may contain a `destination` query parameter.
var $drupalContextualLinks = $('.contextual-links a');
$drupalContextualLinks.each(function() {
var $link = $(this),
linkURL = $link.attr('href');
$link.attr('href', URI(linkURL).removeQuery('destination').toString());
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment