Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

userscript not executed in iframe #1034

Closed
Loceka opened this issue Sep 21, 2020 · 6 comments
Closed

userscript not executed in iframe #1034

Loceka opened this issue Sep 21, 2020 · 6 comments

Comments

@Loceka
Copy link

Loceka commented Sep 21, 2020

I am trying to execute a userscript on https://www.youtube.com which contains an iframe pointing to https://consent.google.com :

// ==UserScript==
// @name          youtube.com
// @namespace     youtube.com
// @include       https://www.youtube.com*
// @include       https://consent.youtube.com*
// @include       https://consent.google.com*
// @grant         none
// @run-at        document-start
// ==/UserScript==

(function() {
    console.log(location.hostname);
})();

On youtube, it only displays the youtube URL, not the one of the iframe.
On consent.google.com, it displays the consent.google.com URL, which discards an @include problem.

Other iframes on other pages work fine, but not this particular one.

@Loceka
Copy link
Author

Loceka commented Sep 21, 2020

My total bad.
The iframe src points to https://consent.google.com but the location is changed server-side to https://consent.youtube.com which explains why it didn't work.

Solved now

@Loceka Loceka closed this as completed Sep 21, 2020
@Loceka Loceka reopened this Sep 24, 2020
@Loceka
Copy link
Author

Loceka commented Sep 24, 2020

I reopen this bug report because although the userscript works in chrome based browsers (at least Chrome and Opera), it doesn't in Firefox.

These are the step to reproduce :

  • install this script
  • open a private navigation window in Firefox (or wipe all the browser cookies)
  • go on any youtube video
  • say "no thanks" to the login popup
  • a policy iframe (also a popup) will appear linked to https://consent.google.com/ in the source code but redirected to https://consent.youtube.com/ server side
  • the "consent.youtube.com" line from the userscript does not appear in the browser console

It does in Chrome/Opera and probably any derivated browser.

Possibly it is due to the fact that Firefox doesn't handle it well when the source iframe URL is different than the load content URL?

@Procyon-b
Copy link

Procyon-b commented Oct 29, 2020

@derjanb
I bumped into this bug today trying to fix an issue a user has with one of my userscripts.
Tried the script in TM, TMbeta, GM and VM. Only violentmonkey works correctly.

after loading the following script in the 4 "monkeys", (choosing a label and a different color), here is what I get

TM-frame bug

Youtube only loads an iframe if there are no cookies. (or use a private window)
Edit: You also sometime have to dismiss the "sign-in" dialog

FF: 82.0.2
TM: 4.11.6117
TM beta: 4.11.6120
GM: 4.10.0
VM: 2.12.7

// ==UserScript==
// @name         Test frames
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  frame bug in TM ?
// @author       You
// @match        https://*.youtube.com/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
"use strict";
var color,label;
//label='TM'; color='background:red;';
//label='TM beta'; color='background:blue;color:white;';
//label='GreaseMonkey'; color='background:green;color:white;';
//label='ViolentMonkey'; color='background:lightblue;';
console.info('%c '+label+' ', color, location.href);
})();

@derjanb
Copy link
Member

derjanb commented Jun 22, 2022

Hmm, sorry for the delay. Can not reproduce at YouTube (because the iframe is not there). There also were a lot architectural changes, which might have fixed this issue.

Can someone please try TM BETA 4.18.6163 (xpi)

You can install it here or check for BETA version updates at about:addons
Please export your settings and scripts as zip or (JSON) file at the "Utilities" tab and import it back at the fixed BETA version.

If the issue persists, then please try the fix mentioned here: #1186 (comment)

Thanks.

@derjanb derjanb added this to the 4.18 milestone Jun 22, 2022
@Procyon-b
Copy link

Procyon-b commented Jun 22, 2022

I've tested with the current versions of FF (101.0.1), TM (4.17.6161), VM (2.13.0). Using uBlock origin logger to check the requests, I can see the script logs 2 yt urls

21:23:05.085  TM  https://www.youtube.com/watch?v=OrBzsEDkA0I&t=1625s [Test frames.user.js:21:9](moz-extension://9cb6fef1-70e0-4500-a0d4-db757de463cc/userscripts/Test%20frames.user.js?id=18249d73-a8e9-45f3-885e-e0a428d5107f)
21:23:05.207  ViolentMonkey  https://www.youtube.com/watch?v=OrBzsEDkA0I&t=1625s[ Test frames.user.js:19:9](moz-extension://ae056953-9889-4c0c-8f5c-ced60a25a815/%20Test%20frames.user.js#2)
21:23:30.774  TM  [https://accounts.youtube.com/accounts/CheckConnection?pmpo=h…2F%2Faccounts.google.com&v=439751163&timestamp=1655925806774](https://accounts.youtube.com/accounts/CheckConnection?pmpo=https%3A%2F%2Faccounts.google.com&v=439751163&timestamp=1655925806774) [Test frames.user.js:21:9](moz-extension://9cb6fef1-70e0-4500-a0d4-db757de463cc/userscripts/Test%20frames.user.js?id=18249d73-a8e9-45f3-885e-e0a428d5107f)
21:23:30.819  ViolentMonkey  [https://accounts.youtube.com/accounts/CheckConnection?pmpo=h…2F%2Faccounts.google.com&v=439751163&timestamp=1655925806774](https://accounts.youtube.com/accounts/CheckConnection?pmpo=https%3A%2F%2Faccounts.google.com&v=439751163&timestamp=1655925806774)[ Test frames.user.js:19:9](moz-extension://ae056953-9889-4c0c-8f5c-ced60a25a815/%20Test%20frames.user.js#2)

From ublock's standpoint, accounts.youtube.com is a frame request. So it appears that it's fixed.
To be sure I'll have to download an old TM (4.11.6117) to verify if the problem still appears with it in the newer FF. But there is a gap between 4.15 and 4.8 in the archive on AMO. Do you still have it available for download?

@derjanb
Copy link
Member

derjanb commented Jun 23, 2022

To be sure I'll have to download an old TM (4.11.6117) to verify if the problem still appears with it in the newer FF.

You can get TM BETA for FF 4.11.6117 from here.

@derjanb derjanb closed this as completed Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants