Created
November 20, 2014 18:55
-
-
Save twslade/257426e0954d9750d5f6 to your computer and use it in GitHub Desktop.
Magento Auto Login - Greasemonkey Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Magento Login | |
// @namespace magento | |
// @include * | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
if(typeof Prototype !== "undefined"){ | |
if(window.location.href.indexOf('.dev') > 0 && $('page-login') && $('loginForm')){ | |
try{ | |
showPopup(); | |
} catch(err) { | |
console.dir(err); | |
} | |
$('username').setValue('thomas'); | |
$('login').setValue('123123'); | |
$('loginForm').submit(); | |
} | |
} | |
function showPopup(){ | |
var docHeight = document.viewport.getHeight(); | |
$$("body").first().insert("<div id='overlay'></div><div id='login-message'>Logging in with GreaseMonkey...</div>"); | |
$("overlay") | |
.setStyle({ | |
'height' : docHeight + 'px', | |
'opacity' : 0.4, | |
'position': 'absolute', | |
'top': 0, | |
'left': 0, | |
'backgroundColor': 'black', | |
'width': '100%', | |
'zIndex': 5000 | |
}); | |
$("login-message") | |
.setStyle({ | |
'height' : '20px', | |
'position': 'absolute', | |
'backgroundColor': 'white', | |
'width': '200px', | |
'zIndex': 5001, | |
'padding': '20px', | |
'border': '5px solid black' | |
}); | |
var vpWidth = $(document).viewport.getWidth(); | |
var width = $("login-message").getWidth(); | |
var avLeft = (vpWidth / 2) - (width / 2) + 'px'; | |
var vpHeight = $(document).viewport.getHeight(); | |
var height = $("login-message").getLayout().get('margin-box-height'); | |
var scrollTop = $(document).viewport.getScrollOffsets().top; | |
var avTop = (vpHeight / 2) - (height / 2) + scrollTop + 'px'; | |
$("login-message") | |
.setStyle({ | |
'top': avTop, | |
'left': avLeft | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment