+
Skip to content

( function ()M { .... }) () statements do not work in *.user.js scripts in Firemonkey #702

Open
@tobwz

Description

@tobwz

As I found out Javascript statements like the following do not work in Firemonkey *.user.js scripts
Although they should work in Greasemonkey.

Can someone confirm this?

I anonymized the @match statement. matching works. Other statements are executed

How can I make them run in Firemonkey on Firefox on Windows?

// ==UserScript==
// @name         Buttons remove (vanilla JS)
// @namespace    http://your.namespace.here
// @version      1.0
// @description  remove Buttons "Kursdaten" and "Chart verkleinern" 
// @match       ......*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function () {
    'use strict';

    function removeButtons() {
        const buttons = document.querySelectorAll('.button-area__button--left');

        buttons.forEach(button => {
            const text = button.textContent.trim();
            if (text === 'Kursdaten' || text === 'Chart verkleinern') {
                button.remove();
            }
        });
    }

    // Initial execute once
    removeButtons();

    // Monitor via MutationObserver
    const observer = new MutationObserver((mutationsList, observer) => {
        for (const mutation of mutationsList) {
            if (mutation.type === 'childList') {
                removeButtons();
            }
        }
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载