• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

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

Hi.

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.


Regards,

Richard.
0
Richard Quadling
Asked:
Richard Quadling
  • 2
2 Solutions
 
leakim971PluritechnicianCommented:
Did you check this PAGE ?

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

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

by :
/* in manifest.json */
"permissions": [
  "tabs", "http://www.yourdomain.com/path/to/yourpage.extension"
]
0
 
Richard QuadlingSenior Software DeverloperAuthor Commented:
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.


0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now