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

[Bug] GM_addElement report TypeError: Illegal invocation when inserting an element from parent into a same-origin frame #2313

Open
F9y4ng opened this issue Dec 27, 2024 · 0 comments

Comments

@F9y4ng
Copy link

F9y4ng commented Dec 27, 2024

Actual Behavior

console report TypeError: Illegal invocation, script stop running.

screenshot_2024-12-27_12-41-32

You can try running the following code on the following site: https://www.xiaolvji.com/ or any site that contains same-origin frame pages.

Specifications

  • Chromium: all
  • TM: all versions
  • OS: win10

Script

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      2024-12-27
// @description  try to take over the world!
// @author       You
// @match        https://*/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        GM_addElement
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';
    window.onload = () => {
        document.querySelectorAll("iframe").forEach(node => {
            const h = node.contentWindow.document.head;
            if (h) {
                const s = GM_addElement(h, "style", {id:"xxxxxxxxxxxx"});
                console.log(s, location.href);
            }
        });
    }
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant