Aoun Raza
Aoun Raza

Reputation: 13

How to paste copied html content from chrome extension into browser body (any input/textarea box) on mouse click event?

*For better understanding see this screen: * https://ibb.co/982MWGB

I want to paste the copied HTML formatted content from my clipboard (that I copied through document.execCommand('copy') in chrome extension) on my browser window, that could be any active tab on the browser and it should be pasted in any input/textarea/rich editor at that range where I click my mouse.

Problem: I am not able to give controls to active tab and not able to paste copied HTML formatted content on my click.

In my case, I made a chrome extension where I have a list of users, so when I click on each user I get the HTML formatted content (not string) copied in clipboard using document.execCommand('copy'); I want this to be pasted in any input/textarea/rich editor where I click my mouse.

Manifest.json looks like

{
    "manifest_version": 2,
    "name": "ChromeExtension",
    "version": "1.0",
    "permissions": [
        "http://*/",
        "https://*/",
        "http://localhost/",
        "http://localhost/chromeextension/",
        "downloads",
        "activeTab",
        "declarativeContent",
        "storage",
        "tabs",
        "webNavigation",
        "notifications"
    ],
    "content_scripts": [{
        "matches": ["http://*/*", "https://*/*"]
    }],
    "content_scripts": [ {
        "matches": ["*://*/*"],
        "js": ["jquery.js", "quilljs.js", "popup.js"]
    }],
    "browser_action": {
        "default_icon": "icon.png",
        "default_title": "Custom Marketing Extension",
        "default_popup": "popup.html"
    },
    "background": {
        "scripts": ["background.js"],
        "persistent": true
    },
    "icons": {
        "16": "icon.png",
        "32": "icon.png",
        "48": "icon.png",
        "128": "icon.png"
    }
}

I want to be able to paste copied content in active tab in the browser window.

Upvotes: 0

Views: 975

Answers (1)

Josh Whiddett
Josh Whiddett

Reputation: 39

Someone else has been able to use localsotrage across multiple tabs. Please see: browser sessionStorage. share between tabs?

Upvotes: 0

Related Questions