On Wed, May 26, 2010 at 7:10 AM, jyothi panidarapu <[email protected]> wrote: > Thanks! I was in a little confusion. > My doubt is how to read the value that is loaded in the tab?
The steps are roughly as follows: 1) Write a script that runs on a given page (or http://* for that matter) and the file: @include http://www.mysite.org/* @include file:///d:/some/folder/filename.txt 2) Load the file into a tab. The script runs by virtue of the second @include 3) The scripts checks the url is running on; since it is 'file:...' it proceeds to read the content of the page: var valueFromFile = document.body.innerHTML (or similar) and stores the value as a preference GM_setValue ('MyValue', valueFromFile) 4) When you load a page from www.mysite.org, the script also runs. In this case, upon having checked that the url is not that of the second include, the sripts loads the value: var storedValue = GM_getValue ('MyValue') This is the basic mechanism. Now come the details: a) you must check and update the stored value periodically, that means that you have to reload the file:/// url every X seconds; I suggested doing that by firing a self-callable function via setTimeout; you have to do this when the url is file:///; after reloading the file, the above logic would apply again and the new value would be written to the preference. b) you must also periodically check whether you have to reload the non-file page because of a changed IP. To this end, after having checked that the url is not the second @include and read the stored value, the scripts decides based on the value whether a page reload is necessary. If yes, it causes a reload (use document.location.reload(true) to reload from the server); There are still a number of details to solve, as to whether to open the file url manually or via GM_openInTab, and to check if a reload has been just triggered in order to prevent an infinite reload loop. These are left as an exercise to the reader ;-) -- You received this message because you are subscribed to the Google Groups "greasemonkey-users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en.
