Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Adding new {grease|tamper}monkey script for the new login page. Also …
Browse files Browse the repository at this point in the history
…adding the exclude pattern for the old one not to conflict with the new script. Now, both scripts can live together and the right one will be used with the corresponding RHQ version. Based on the fact that new login page uses "login" substring in the url.
  • Loading branch information
jkremser committed Apr 22, 2014
1 parent 5ac07de commit 79ef6b8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 17 deletions.
33 changes: 33 additions & 0 deletions etc/greasemonkey/RHQ_login_monkey-before-4.11.user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// ==UserScript==
// @name RHQ login monkey old
// @namespace org.rhq.coregui
// @description Types in the credentials when pressing ALT+C on the login page. This script works also for Chrome/Chromium with the extension called Tampermonkey. This version works well with the RHQ 4.10 and lower.
// @include *:7080/coregui/*
// @include *:7080/coregui/#LogOut
// @exclude *:7080/coregui/login*
// @grant none
// @author Jiri Kremser <jkremser@redhat.com>
// @version 1.1
// ==/UserScript==

function fillTheCredentials() {
document.getElementsByName("user")[0].value="rhqadmin";
document.getElementsByName("password")[0].value="rhqadmin";
//document.forms[0].submit() doesn't work, SmartGWT uses internal logic
document.getElementsByName("password")[0].focus();
}

// register the function and the hot key
//GM_registerMenuCommand("Fill the credentials", function(e) {
// fillTheCredentials();
//}, "c", "alt", "c" );

// fallback solution, because the function above doesn't work in all browsers
(function(){
document.addEventListener('keydown', function(e) {
// pressed alt+c
if (e.keyCode == 67 && !e.shiftKey && !e.ctrlKey && e.altKey && !e.metaKey) {
fillTheCredentials();
}
}, false);
}());
33 changes: 16 additions & 17 deletions etc/greasemonkey/RHQ_login_monkey.user.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
// ==UserScript==
// @name RHQ login monkey
// @namespace org.rhq.coregui
// @description Types in the credentials when pressing ALT+C on the login page. This script works also for Chrome/Chromium with the extension called Tampermonkey.
// @include *:7080/coregui/*
// @include *:7080/coregui/#LogOut
// @description Types in the credentials when pressing ALT+C on the login page. This script works also for Chrome/Chromium with the extension called Tampermonkey. This script works with the new login screen that was added to RHQ 4.11
// @include *:7080/coregui/login*
// @grant none
// @author Jiri Kremser <jkremser@redhat.com>
// @version 1.1
// @version 1.2
// ==/UserScript==

function fillTheCredentials() {
document.getElementsByName("user")[0].value="rhqadmin";
document.getElementsByName("password")[0].value="rhqadmin";
//document.forms[0].submit() doesn't work, SmartGWT uses internal logic
document.getElementsByName("password")[0].focus();
// new UI
document.getElementById('inputUsername').value="rhqadmin";
document.getElementById('inputPassword').value="rhqadmin";
document.getElementById('loginForm').submit();
}

// register the function and the hot key
GM_registerMenuCommand("Fill the credentials", function(e) {
fillTheCredentials();
}, "c", "alt", "c" );
//GM_registerMenuCommand("Fill the credentials", function(e) {
// fillTheCredentials();
//}, "c", "alt", "c" );

// fallback solution, because the function above doesn't work in all browsers
(function(){
document.addEventListener('keydown', function(e) {
// pressed alt+c
if (e.keyCode == 67 && !e.shiftKey && !e.ctrlKey && e.altKey && !e.metaKey) {
fillTheCredentials();
}
}, false);
document.addEventListener('keydown', function(e) {
// pressed alt+c
if (e.keyCode == 67 && !e.shiftKey && !e.ctrlKey && e.altKey && !e.metaKey) {
fillTheCredentials();
}
}, false);
}());

0 comments on commit 79ef6b8

Please sign in to comment.