I am developing a Chrome extension, and my requirement is to create an element (button) on the page for each open tab and wants to show a simple warning message when the button is pressed .. it works correctly for everyone, but it always creates a problem with Gmail, Facebook and stackoverflow..please help me solve this problem.
I have a code to add a button to a webpage in my Content script.
manifest.json .... .... "content_scripts": [ { "matches":["http://*/*", "https://*/*"], "css": [ "style.css" ], "js":["contentScript.js"], "all_frames": false, "run_at": "document_idle" } ] .... ....
contentScript.js
.... .... function addButton() { document.body.innerHTML += '<button id="my_button" class="buttonCss">Show Button</button>'; var button = document.getElementById("my_button"); button.addEventListener("click", function () { alert("hello"); }, false);
} ..... ..... ....
I think some Gmail security features are creating a problem.
source share