Expected Behavior
Adding functions to unsafeWindow works, eg on youtube:
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 2024-11-02
// @description try to take over the world!
// @author You
// @match https://www.youtube.com/watch?v=Bv1LVYtdGGo
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant unsafeWindow
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
unsafeWindow.test1 = "test"
unsafeWindow.test2 = () => "test"
})();

Actual Behavior
Running the following userscript gives:
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 2024-11-02
// @description try to take over the world!
// @author You
// @match https://x.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=x.com
// @grant unsafeWindow
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
unsafeWindow.test1 = "test"
unsafeWindow.test2 = () => "test"
})();

Functions cannot be accessed in any way. (Probably a CSP issue?)
Tested while disabling all other scripts.
Specifications
- Firefox: 132.0
- TM: 5.3.1
- OS: Windows 10
Expected Behavior
Adding functions to unsafeWindow works, eg on youtube:
Actual Behavior
Running the following userscript gives:
Functions cannot be accessed in any way. (Probably a CSP issue?)
Tested while disabling all other scripts.
Specifications