Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8549825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:48:34+00:00 2026-06-11T13:48:34+00:00

I’m a beginner in JavaScript. I need to know if this is possible and

  • 0

I’m a beginner in JavaScript. I need to know if this is possible and then if so, how to do it.

I’d like to create a Greasemonkey script that will automatically reload a webpage every hour, and then after reloading the page, I’d like it to click a button for me.

Is that possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:48:36+00:00Added an answer on June 11, 2026 at 1:48 pm
    • For clicking stuff, see this answer.

    • See also a javascript reference for location.reload().

    • See also a better javascript reference for setTimeout().

    • Since the button may be loaded via AJAX (Need more information in the question), reference the waitForKeyElements() utility, for dealing with AJAX delays/modifications.

    • Start learning jQuery; it will save you a ton of grief and effort.

    • Identify the jQuery selector for the button you want. You can use tools like Firebug to help with this (Note that jQuery selectors and CSS selectors are mostly the same, but jQuery has more options/power).

      For example, if the page’s HTML had a section that looked like this:

      <div id="content">
          <p>Blah, blah, blather...</p>
      
          <h2>Your available actions:</h2>
          <button class="respBtn">Like</button>
          <button class="respBtn">Hate</button>
          <button id="bestOption" class="respBtn">Nuke them all</button>
      </div>
      

      Then selectors for the 3 buttons might be (respectively):

      1. $("#content button.respBtn:contains('Like')");
      2. $("#content button.respBtn:contains('Hate')");
      3. $("#bestOption"); (Always use the id, if the element has one.)

    Putting it all together, here is a complete Greasemonkey script that reloads and clicks:

    // ==UserScript==
    // @name     _Reload and click demo
    // @include  http://YOUR_SERVER.COM/YOUR_PATH/*
    // @require  http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
    // @require  https://gist.github.com/raw/2625891/waitForKeyElements.js
    // @grant    GM_addStyle
    // ==/UserScript==
    /*- The @grant directive is needed to work around a major design
        change introduced in GM 1.0.
        It restores the sandbox.
    */
    
    waitForKeyElements ("#bestOption", clickTargetButton);
    
    function clickTargetButton (jNode) {
        var clickEvent = document.createEvent ('MouseEvents');
        clickEvent.initEvent ('click', true, true);
        jNode[0].dispatchEvent (clickEvent);
    }
    
    //--- Reload after 1 hour (1000 * 60 * 60 milliseconds)
    setTimeout (location.reload, 1000 * 60 * 60);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I need a function that will clean a strings' special characters. I do NOT
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to create an if statement in PHP that prevents a single post
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.