First steps with MV3: reading the clipboard and editing the contextMenu

112 views Asked by At

In my backkground.js file of my MV2 extension, I get the clipboard text value with

    if(document.getElementById('filteredClipboard_data') == null){
        var ta = document.createElement('textarea');
        ta.id = 'filteredClipboard_data';
        document.body.appendChild(ta);
    }
    ta = document.getElementById('filteredClipboard_data');
    ta.value = '';
    ta.select(); 
    if ( document.execCommand("Paste", null, null)) {
        data =  ta.value;
    } else {
        log("paste failed");
    
    }
    ta.value = '';
    return data;

It's my understanding that this won't work with a service worker script. Correct ? I would also know if manupulating the context menu from the service worker is possible :

    chrome.contextMenus.create({
    title: menu.title,
    id: menu.fcb_context,
    contexts: menu.context,
    });

Is that possible in a service worker script ?

Thanks

François

0

There are 0 answers