Google Chrome User script to automate clicking 2 links when the links become visible.

Posted on 2011-10-24
Last Modified: 2012-08-13

I've never written a Google Chrome User Script before.

There is a website that periodically opens a modal popup. The popup requires acceptance before the underlying page will be updated. When the popup isn't present the page updates automatically.

The popup does 2 things.

1 - A <div> with an ID of "confirm-acceptance" becomes visible (CSS display changed).
2 - The div contains an <a> with an onclick event of fn_AcceptanceConfirmed();

So, I want the script to call fn_AcceptanceConfirmed(); when the <div id="confirm-acceptance"> is visible.

Is this possible? Checking once every 10 minutes or so would be fine.

Clues or code would be great.

There are 2 links, but if the first one can be explained, then I can do the second.


Question by:RQuadling
    LVL 81

    Accepted Solution

    Did you check this PAGE ?

    /* in background.html */
    chrome.browserAction.onClicked.addListener(function(tab) {
                               {code:"setInterval(function() { fn_AcceptanceConfirmed(); }, 10 * 60 * 1000);"});

    /* in manifest.json */
    "permissions": [
      "tabs", "http://*/*"
    LVL 81

    Assisted Solution

    replace :
    /* in manifest.json */
    "permissions": [
      "tabs", "http://*/*"

    by :
    /* in manifest.json */
    "permissions": [
      "tabs", ""
    LVL 40

    Author Comment

    Thanks for that. I now need to work out how I call the click event. DispatchEvent/FireEvent logic it seems.

    Cannot call the method directly due to SOP.

    You've pushed me in the right direction.


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
    The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now