On 2010-05-29 21:59, jyothi panidarapu wrote:
Following is the modified code, still it didn't work. This alert box is not popping out. I am using firefox 3.5.3.

Do these API's work for this version of firefox?
// ==UserScript==
// @key value
// @name : Reload the page if there is any change in Ip address of the system
// namespace


// @Description:
// @include http://*
// @include file://*
// ==/UserScript==



window.setInterval("checkIpChange()",2000);  // Call the function every 2 
seconds

As explained, this cannot work. Use this instead:

window.setInterval(checkIpChange,2000);  // Call the function every 2 seconds


function  checkIpChange()
{
                GM_xmlhttpRequest(


                {
                method:  'GET',
                url:  'http://localhost/readValue.txt',


                headers:
                {       
                'User-agent':  'Mozilla/3.5 (compatible) Greasemonkey',


                'Accept':  'text/xml',

I don't know why you're setting this Accept header this way... either leave it out entirely, or set it to something reasonable. XML just ain't it ;-) . Try this instead, for plain text:

                'Accept':  'text/plain',

(Since this is running on the localhost, it's not likely to make much difference, if any, unless you set up an Apache instance or whatever to return different resource representations on different Accept header.)
                },


                onload:  function(responseDetails)  //My text file entry would 
be either '0' or '1'


                {
                alert('Request for Atom feed returned'  +  
responseDetails.status+  ''  +  responseDetails.statusText+  '\n\n'  +


        'Feed data:\n'  +  responseDetails.responseText);


                        change=  responseDetails.responseText;
                        if(change==1)


                        {
                                window.location.reload();
                        }


                        else
                        {
                                //Do Nothing
                        }
                

                }


                }
                );
}








On Sat, May 29, 2010 at 10:55 PM, jyothi panidarapu <[email protected] <mailto:[email protected]>> wrote:



    On Sat, May 29, 2010 at 9:46 PM, cc <[email protected]
    <mailto:[email protected]>> wrote:

        On 2010-05-29 08:44, jyothi panidarapu wrote:
        I have installed and tried it. There was no affect after
        installation. Can somebody tell me what's wrong with it?

        On Wed, May 26, 2010 at 6:23 PM, jyothi panidarapu
        <[email protected]
        <mailto:[email protected]>> wrote:

            I am including the script that I have written, please
            tell me if something is wrong.  I haven't installed yet,
            before that I have read up how to test it.


            // ==UserScript==
            // @key value
            // @name : Reload the page if there is any change in Ip
            address of the system
            // namespace
            // @Description:
            // @include http://*
            // @include file://*
            // ==/UserScript==

            window.setInterval("checkIpChange()",2000); // Call the
            function every 2 seconds

        This line should be
            window.setInterval(checkIpChange,2000); // Call the
        function every 2 seconds
        as otherwise it will try to call an undefined function. (See
        http://wiki.greasespot.net/Avoid_Common_Pitfalls_in_Greasemonkey
        for more detail, specifically the Auto-Eval Strings section.)

    Okay I will look into it.


            var protocol= location.protocol;
            var pattern= file:


        Not sure what this line is trying to do, exactly. Maybe
        something got left out in copy+paste?


            function checkIpChange()
            {
                protocol= location.protocol;
                if( protocol.match(pattern)
                {
                    window.location.reload();
                }
                else
                {
                    GM_xmlhttpRequest(
                    {
                        method: 'GET',
url: 'http://localhost/readValue.txt', // file which contains the value
                        headers:
                        {
                            'User-agent': 'Mozilla/4.0 (compatible)
            Greasemonkey',
                            'Accept':
            'application/atom+xml,application/xml,text/xml',


        Are you really requesting Atom and XML? It seems like this
        would be more likely to require text/plain.

        No, I just want to access the text.

                        },
                        onload: function(responseDetails) //My text
            file entry would be either '0' or '1'
                        {
                            /*alert('Request for Atom feed returned '
            + responseDetails.status + ' ' +
            responseDetails.statusText + '\n\n' +
                                'Feed data:\n' +
            responseDetails.responseText);*/
                        change= responseDetails.responseText ;
                        if(change==1)
                        {
                            window.location.reload();
                        }
                        else
                        {
                            //Do Nothing
                        }


                        }
                    }
                    );
                }
            }



            Thanks
            Jyoti

            On Wed, May 26, 2010 at 12:11 PM, cc
            <[email protected] <mailto:[email protected]>> wrote:

                Give it a go, it should work. (Also, in general: it's
                often faster just to try a naive test, and if it
                works, you're golden; asking the group takes longer
                and more of our time.)


                On 2010-05-25 23:35, jyothi panidarapu wrote:
                I have a small doubt.
                if I load the text file on my local web server, can
                I read the value of it using GM_xmlhttprequest() ?
                http://localhost/myfile.txt

                On Wed, May 26, 2010 at 11:28 AM, esquifit
                <[email protected]
                <mailto:[email protected]>> wrote:

                    Here you can find some inspiration:

                    
http://groups.google.com/group/greasemonkey-users/browse_thread/thread/21ad5af3c7cc4b00

-- cc | pseudonymous |<http://carlclark.mp/>


-- ~ Smash forehead on keyboard to continue.... ~
        http://tagzilla.mozdev.org v0.066
-- 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]
        <mailto:[email protected]>.
        To unsubscribe from this group, send email to
        [email protected]
        <mailto:greasemonkey-users%[email protected]>.
        For more options, visit this group at
        http://groups.google.com/group/greasemonkey-users?hl=en.




-- - Jyothi
    M.Tech,CSE
    IITMadras




--
- Jyothi
M.Tech,CSE
IITMadras
--
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. Download MSN Messenger: Get MSN Messenger 2010 Instantly Includes 10,000 Bonus Smileys Free
http://click.lavabit.com/?r=MTYyNjQx

--
cc | pseudonymous |<http://carlclark.mp/>

--
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.

Reply via email to