Years ago, I saw Jeff's Handy Dandy Drupal Login Bookmarklet, a bookmarklet that made it easy to log in to any Drupal site. You'd just click on this bookmark, it would detect that it was a Drupal site, and send you to the login page with the current page set as the "destination" so that you'd get sent back to that page after logging in. With Drupal 8, though, this bookmarklet no longer worked due to Javascript changes.
Here's an updated version that works on both Drupal 8 and 7 sites. It should work on Drupal 6 sites, too. Although, if you've still got a Drupal 6 site, you should talk to us about upgrading to Drupal 8!
Just drag the above link to your browser's bookmarks bar and click it when you're on any Drupal site.
Here's the updated Javascript code, if you're interested:
(function () {
var l = window.location;
var h = l.hash || '';
var s = l.search || '';
if (typeof Drupal != 'undefined' && typeof drupalSettings != 'undefined') {
if (typeof jQuery != 'undefined' && jQuery('body.user-logged-in').length) {
if (!confirm("It looks like you're already logged in. Continue?")) {
return;
}
}
var b = drupalSettings.path.baseUrl;
var p = l.pathname.slice(b.length) || '/';
window.location.href = l.protocol + "//" + l.host + b + "user/login?destination=" + encodeURIComponent(p + s + h);
} else if (typeof Drupal != 'undefined' && typeof Drupal.settings != 'undefined') {
if (typeof jQuery != 'undefined' && jQuery('body.logged-in').length) {
if (!confirm("It looks like you're already logged in. Continue?")) {
return;
}
}
var b = Drupal.settings.basePath;
var p = l.pathname.slice(b.length) || '<front>';
window.location.href = l.protocol + "//" + l.host + b + "index.php?q=user&destination=" + encodeURIComponent(p + s + h);
} else {
alert("This doesn't appear to be a Drupal site.");
}
})();
I used Peter Coles' bookmarklet creator to convert the Javascript into a bookmarklet.
Comments