4

I usually have to visit a website:

https://xyz.asd.com/maximo/ui/maximo.jsp?sc=4325286581&event=loadapp&value=incident

that contains the following line in it's HTML code:

SESSION_TIMEOUT = 1800;//in seconds.

I need to change this string to ex.:

SESSION_TIMEOUT = 1800000;//in seconds.

Greasmonkey can do this. But how? I kept googling for hours, but the original line is untouched... Can someone help me?

5
  • Is SESSION_TIMEOUT a global JavaScript variable?
    – cmorse
    Dec 5, 2011 at 0:12
  • @cmorse - I think its responsible for the webpage to timeout/log out the logged in user. Dec 5, 2011 at 0:22
  • @LanceBaynes - I was thinking that if it is just a JavaScript variable then you could just set it to the desired value with a greasemonkey script.
    – cmorse
    Dec 5, 2011 at 0:26
  • @LanceBaynes: You should look for a browser-specific solution to access the original window context, this can differ between browsers. It could be so that the session timeout is somehow forced on you (perhaps by a timer or AJAX calls), in which case you aren't able to change it. Also note that changing a client-side timeout won't impose a server-side timeout change... Jan 8, 2012 at 19:01
  • Why don't you change the session time out in Maximo application? If you use LDAP, there is also an LDAP token that expires that is separate from the session time out if you use WebSphere application server.
    – Sun
    Mar 31, 2015 at 19:22

3 Answers 3

2
// ==UserScript==
// @name          Script Name Here
// @namespace     http://www.site.com/your-personal-namespace
// @description   An Greasemonkey script that changes the session timeout value
// @include       https://xyz.asd.com
// ==/UserScript==
window.SESSION_TIMEOUT = 1800000;

?

4
  • this one doesn't work too :\ Jan 7, 2012 at 15:05
  • can you provide more details? how have you checked that it doesn't work - have you used, for example, javascript console to check if the variable was changed or not? is there an error message?
    – eis
    Jan 7, 2012 at 19:57
  • The version with unsafeWindow should work. Mine does not seem to, but cannot comment on that one, so commented here. But please add some more details as to why that one does not work.
    – eis
    Jan 7, 2012 at 20:05
  • @eis: window doesn't give full access, unsafeWindowis browser-dependent. Jan 8, 2012 at 2:14
2

You'll want to use unsafeWindow, which, as the name infers, is not the most secure method -- but if all you are doing is changing the value of a page based variable, there's no risk involved.

// ==UserScript==
// @name          Script Name Here
// @namespace     http://www.site.com/your-personal-namespace
// @description   An Greasemonkey script that changes the session timeout value
// @include       https://xyz.asd.com
// ==/UserScript==

unsafeWindow.SESSION_TIMEOUT = 1800000;

If you just use window.SESSION_TIMEOUT, you more than likely will not be accessing the correct scope, and your SESSION_TIMEOUT variable would go unmodified, and a new one created inside another context / scope.

7
  • it doesn't work, sorry :\ Jan 7, 2012 at 15:05
  • @lawrencealan: unsafeWindow is browser-dependent. Jan 8, 2012 at 2:14
  • @TomWijsman Where do you see that unsafeWindow is browser dependent? It was my understanding that it is implemented in the GreaseMonkey plugin itself...
    – L422Y
    Jan 9, 2012 at 16:50
  • @LanceBaynes try using a timer, I have a feeling that the value is being overwritten due to the order of inclusion, but I could be wrong.
    – L422Y
    Jan 9, 2012 at 16:53
  • 1
    @TomWijsman Greasemonkey is officially only an extension for Mozilla Firefox, other browsers are not guaranteed to work.
    – L422Y
    Jan 9, 2012 at 21:05
0

Good old

location.href="javascript:(function(){ window.SESSION_TIMEOUT = 1800000; })()"

trick should work.

3
  • Can I ask how to implement this? to a userscript?? Jan 8, 2012 at 6:22
  • I tried it in a userscript. it doesn't work either :D:D maybe the Maximo tool is based on something that overrides this somehow...it's a mistical thing for me... Jan 8, 2012 at 6:33
  • @LanceBaynes: Although my code should work, here is a Q&A explaining this trick and another trick. I've used the script trick before as well as well as that location trick and the one I mentioned. If none of these work, you simply can't do anything with that value. It might even be so that that value is solely used to start a timer and later not used anymore in any way... Jan 9, 2012 at 20:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .