1

I have a userscript where I'm using Tampermonkey to change a DOM element's text. This code

$(".widget-container_cimta_revenue_kpi_number").find('div.count')
                                               .text('$50,000')
                                               .css('fontSize', 24);

works fine in Chrome Dev Tools > Console Log as long as I set the "execution context" manually in the dropdown from "top" to "waveApexPage". see dropdown value for execution context

Is there a way to programmatically change the execution context value in this dropdown inside chrome dev tool? I believe it is the global execution context?

Tibrogargan
  • 4,508
  • 3
  • 19
  • 38
Jimmy T
  • 11
  • 1
  • (Probably you can't.) Instead you should modify the `@include` or `@match` URL to match the href attribute of the iframe you intend to target. – Nisarg Shah Sep 13 '18 at 05:19
  • Thanks Nisarg. Was suspecting that was the case.. However, when I view source, I do not see any references to iframe. Is there an example where I can target a specific div class with @include or @match? – Jimmy T Sep 13 '18 at 05:46
  • 1
    That `waveApexPage` you see should be an iframe element. You should be able to find it via the elements panel. It's possible that it is added via Javascript at a later stage, so it might not appear in the source you are looking at. – Nisarg Shah Sep 13 '18 at 05:48
  • I see the iframe waveApexPage now. Do you have an example of how I can target that with @include? I see this: https://stackoverflow.com/questions/37616818/apply-a-greasemonkey-tampermonkey-userscript-to-an-iframe but doesn't look like what I want... – Jimmy T Sep 13 '18 at 05:57
  • Now you are matching with the href value of that iframe. If you want to omit some part of it, you can use `@include` and then put `*` in the part that you intend to omit. It should be straightforward. – Nisarg Shah Sep 13 '18 at 05:59

0 Answers0