Skip to content

Instantly share code, notes, and snippets.

@awolfey
Last active December 28, 2015 22:39
Show Gist options
  • Save awolfey/7573658 to your computer and use it in GitHub Desktop.
Save awolfey/7573658 to your computer and use it in GitHub Desktop.
A backtick.io command to automatically log you into a Drupal site, with the option to change protocols. Based on / stolen from http://www.lullabot.com/blog/article/jeffs-handy-dandy-drupal-login-bookmarklet
if (typeof Drupal != "undefined" && typeof Drupal.settings != "undefined") {
var u = false;
if (typeof jQuery != "undefined" && jQuery("body.logged-in").length) {
if (!confirm("It looks like you're already logged in. Continue?")) {
return;
}
}
var o = window.location.protocol;
var l = window.location;
var h = l.hash || '';
var s = l.search || '';
var b = Drupal.settings.basePath;
var p = l.pathname.slice(b.length) || '<front>';
var ko = confirm("Continue using " + o + "?");
if (!ko) {
o = o == 'https:' ? 'http:' : 'https:';
}
window.location.href = o + "//" + l.host + b + "index.php?q=user&destination=" + escape(p + s + h);
setTimeout(function(){document.getElementById("edit-submit").focus()}, 3000);
}
else {
alert("This doesn't appear to be a Drupal site.");
}
{
"name": "Drupal Login",
"description": "If this is a Drupal site you'll hit the login page and redirect back.",
"icon": "",
"link": ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment