Trying to create chrome extension to hide iframe content from a page - google-chrome-extension

im working to create a very simple chrome extension just to remove an annoying tag from a site here is my codes
my manifest.json file include those lines :
{
"manifest_version": 2,
"name": "RemoveMysatgoHelp",
"description": "Remove Mysatgo Help tag",
"version": "1.0",
"icons": {
"16": "imgs/16.png",
"32": "imgs/32.png",
"64": "imgs/64.png",
"128": "imgs/128.png"
},
"content_scripts": [
{
"matches": [
"*://*.mysatgo.com/*"
],
"js": [
"content.js"
],
"run_at": "document_idle"
}
]
}
my content.js file include this single line:
var elements0 = document.getElementById('launcher');
elements0.style.display='none';
i need to remove these "Help window"at the bottom of the page it disturbing the main player control, here is my illustration https://prnt.sc/qaeaf5
i believe it is a dynamic tag inside an anonymous div tag ,the only id name that we have is within the iframe tag and the idname is "launcher"
my question
the problem again the elements0 return null ,because it seems the page not fully loaded with all the sources
any solution ?
Thanks

Related

Chrome extension not loading content_scripts

I am creating a chrome extension. Problem I am facing is I am able to see the html content but I am not seeing my js files included in content_scripts. I am checking this by inspecting on my extension & checking sources tab.
Mainfest -
{
"manifest_version": 2,
"name": "My Plugin",
"description": "some description",
"version": "1.0",
"browser_action": {
"default_popup": "popup.html"
},
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"js": ["myPopup.js"]
}
],
"permissions": [
"activeTab",
"declarativeContent",
"storage"
]
}
myPopup.js -
console.log("hello world")
What could I be doing wrong?
Source tab will display the scripts that are actually injected into page DOM.
If you are trying to debug the content script, then add a debugger to your content script.
Open the developer tools and reload the page, you should be able to see content script in the source tab.
enter image description here

Chrome Extension icon not having color

I just create my first Chrome extension. My extension's icon shows correctly (with color) in the extension manager page:
But Chrome shows a grayscale version of my icon in the extension bar:
Here's the manifest of my extension:
{
"name": "__MSG_appName__",
"version": "0.0.1",
"manifest_version": 2,
"description": "__MSG_appDescription__",
"icons": {
"16": "images/icon-16.png",
"128": "images/icon-128.png"
},
"default_locale": "en",
"background": {
"scripts": [
"scripts/chromereload.js",
"scripts/background.js"
]
},
"permissions": [
"tabs",
"http://*/*",
"https://*/*",
"contentSettings"
],
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"js": [
"scripts/contentscript.js"
],
"run_at": "document_end",
"all_frames": false
}
]
}
What can I do to make Chrome show my icon with color next to the address bar?
Thanks
That is odd behaviour, I don't know why it's happening but I know the solution: you should be using default_icon instead of icon:
"browser_action": {
"default_icon": "icon.png"
}
Note that the icon needs to be 19x19 or 38x38 pixels.
You've defined the larger icon correctly though so you could leave that as is.
See here for more info.
Based on my experience and on Noam's answer I'm tempted to say that it is because your extension doesn't have a "browser_action" defined. In other words: its icon is there to show it is installed, but it doesn't do anything, so it had its colors removed.
This is just a guess not confirmed by any documentation or test.
The other responses are working, but only for manifest_version <= 2. for version 3, instead of browser_action just action. for more details on other keywords check here

URL with fragment chrome extensions

I have a little problem whit my chrome extension.
The extension works if I'm on a URL that not uses fragment.
Now sure on how to configure it.
Im trying with definition < all_urls > but as I wrote. it does not work on pages with fragment.
manifest.json
{
"update_url": "https://clients2.google.com/service/update2/crx",
"name": "Analytic Live Alarm",
"version": "0.3",
"description": "Felipe the solution provider",
"permissions": [
"tabs","<all_urls>"
],
"browser_action": {
"default_icon": "icon.png"
},
"icons": {
"16": "icon.png",
"48": "icon.png",
"128": "icon_128.png"
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"run_at": "document_end" ,
"js": ["jquery.min.js", "script.js"]
}
],
"manifest_version":2
}
This is the url Im using.
https://www.google.com/analytics/web/#dashboard/6I8yfVs_TqSQ_b1tOJYR0Q/a8398197w15972131p74378741/
Any ideas?
Thanks
Taking into account your previous question..
It's not "not working", it's working once; then, as you navigate, the page is not really reloaded, and your script does not run again.
Instead of coloring all elements at document_end, you need to detect new elements that match your selector and re-apply your styles.
This question should help you get started, or better yet mutation-summary library.

Chrome Extensions - Script works only once, when I download a page the first time

The problem is that after it downloads the page the first time, it works, but if I click on "home" link, the script doesn't work anymore.
manifest:
{
"manifest_version": 2,
"name": "Facebook No Advs",
"description": "This extension TRY to avoid advertisement from Facebook Home.",
"version": "1.0",
"permissions": ["https://www.facebook.com/*"],
"content_scripts": [
{
"matches": ["https://www.facebook.com/*"],
"js": ["jquery-1.11.0.min.js", "noAdvsScript.js"],
"css": ["NoAdvsStyle.css"]
}
]
}

chrome extension doesn't load

made my first chorme ext. and it works fine on old comp.
now with new one try to load unpacked ext. and it don't works at all. i see my ext popup ad bg.html but content script didn't loads at all, neiter images that shold be on target page.
other unpacked ext works fine. but mine refuse works( help me please!
manifest.json:
{
"background_page": "bg.html",
"name": "lardi trans",
"version": "1.0",
"icons": {
"48": "icon_48.png"
},
"browser_action": {
"default_icon": "icon_48.png",
"default_title": "Lardi Trans",
"default_popup": "popup.html"
},
"permissions": [
"tabs",
"notifications",
"http://lardi-trans.com/gruz/*",
"http://lardi-trans.com/trans/*",
"unlimitedStorage"
],
"content_scripts": [{
"matches": [
"http://lardi-trans.com/gruz/*",
"http://lardi-trans.com/trans/*"
],
"css": ["extent_styles.css"],
"js": ["jq.js", "script.js"],
"run_at": "document_end"
}]
}
screenshots of page where ext should be i mark place where must appears my form
console shot
and other ext scripts loads like this ! screenshot2 (5 times same script? WTF??) but anyway i can't see my ext script.js (why it din't loads?)
You do not have to give the link of css to manifest.json file. Just, call it in bg.html
My manifest.json file
{
"name": "Example",
"version": "2.0",
"description": "Example.com Description",
"icons": { "16":"Images/Example/16x16.png", "32":"Images/Example/32x32.png", "48": "Images/Example/48x48.png", "64": "Images/Example/64x64.png", "128": "Images/Example/128x128.png" },
"app":
{
"default_icon": "../Images/Example/icon.png",
"launch":
{
"local_path": "Pages/Index.html"
}
},
"permissions": [ "http://www.Example.com/",
"http://*.Example.com/",
"https://www.Example.com/",
"https://*.Example.com/",
"unlimitedStorage",
"tabs",
"notifications"
],
"options_page": "Pages/Options.html",
"background_page": "Pages/Background.html"
}
If that answer helped you, please mark it as an answer...
If you are still taking errors, please ask them to bottom of that answer.
Best Regards.
EDIT:
View errors - Steps;
Click your extension button to open it.
Open the debug window in Google Chrome with F12 key.
Click "Console" tab page.
Take a screenshot of it, and post the picture in your question.
With that way everybody can help you =)
EDIT 2:
ok your question seems looking littlebit different now.
Here is algorithm;
Download the site sourcecode of target webpage with jquery,
Insert your css line in head tag with json,
Store new source code in localStorage( html5 )
When it's done, refresh the page with js, and read new source code from localStorage
And show it in html.
if anyone interests, problem solved, by some reason in manifest add unprop whitespases "content_scripts": [{
"matches": ["http://lardi-trans.com/gruz/*","http://lardi-trans.com/trans/*"],
this works!))

Resources