Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Small question about greasemonkey 1

Status
Not open for further replies.

iranor

Programmer
Jun 17, 2004
174
CA
Is it possible to make tab-specific variable? Let's say you open two time the same website in different tabs, when you use GM_setValue, it's gonna change the data for both tabs.

I've been looking for some time on google, but I couldn't find anything, or maybe I didn't formulate it correctly.

My script use a Step variable to know to wich task we are up to, and if I run this in two different tab, you see the mess...

Thanks!
 
Hi

Not possible with GreaseMonkey's API, but is not necessary anyway. Use the browser's own [tt]sessionStorage[/tt] object :
Code:
// ==UserScript==
// @name           test
// @include        *
// ==/UserScript==

if (sessionStorage.whatever) alert('Our secret is '+sessionStorage.whatever)
else sessionStorage.whatever=prompt('Say something only to me')


Feherke.
 
At first I thought it was another browser-wide session, but that's exactly what I was looking for.

Thanks a lot :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top