Greasemonkey - click inside iFrame

Scorpion Ghost

Elite Member
Executive VIP
Jr. VIP
Joined
Mar 22, 2013
Messages
9,143
Reaction score
10,489
So I'm trying to get Greasemonkey to click inside an iFrame, but without adding the iFrame's URL as a "@match" in the script.

So I have this script (it focuses a field and clicks something on a dropdown):

Code:
// ==UserScript==
// @name           My Script
// @match          https://somesite.com/page
// @match          https://somesite.com/pageframed
// @require        http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @grant           none
// ==/UserScript==


var input = $('#url');
input.focus();


var categoryID = 29;
var categoryName = "Some Name";
 
/* Find <select> selector */
var type = document.getElementById('my-type');
var chosen = document.getElementById('select2-chosen-1');
 
/* Set Category */
type.value = categoryID;
chosen.innerText = categoryName;

See the "@match" rules I added in the code.

This is the page I am on - https://somesite.com/page

This is the page within the iFrame - https://somesite.com/pageframed

And the script works great. But the moment I remove the "@match" of the URL which opens in the iFrame - // @match https://somesite.com/pageframed - the script stops working.

So I know Greasemonkey can click inside of the iFrame, clearly it clicks when the proper "@match" attribute is there. But how to make it click the stuff regardless?

May be a bit tricky, I'm not sure. But I'm sure some javascript jquery black magic insanity can pull it off.

Possible? Any ideas? @Gogol
 
I'm reading on it. I thought maybe I can use @match and @Include for this.

So that the script is applied only if both the @match and @Include URLs are present on the page.

But it seems it doesn't work that way.
 
Back
Top