Would a colon in matches URL break my chrome extension? - google-chrome-extension

There is a site that I'm using that has a horrible interface. I wanted to "fix it up a bit" and insert some custom CSS. I have my chrome extension working using google.com but can't get it to work on the target site. The only thing I can work out is maybe it's because of the colon in the matches URL?
http://subdomain.subdomain.subdomain.edu.au:82/Folder/
Strangely the javascript I have done does work (adds a class to ) so I am thinking maybe there is something else that is a problem. Also note that the target site is behind the u/p but is not on a https server - does this matter?
Here is the complete manifest.json
{
"manifest_version": 2,
"name": "Test",
"description": "Makes the site prettier.",
"version": "1.5",
"author": "daniel",
"icons": { "16": "/icons/icon16.png",
"48": "/icons/icon48.png",
"128": "/icons/icon128.png"
},
"content_scripts": [{
"matches": ["http://subdomain.subdomain.subdomain.edu.au:82/Folder/*"],
"css": ["style.css"],
"js": ["script.js"]
}]
}
and here is the CSS file:
html body.customclass {background-color: #FF0;}
and here is the JS file:
document.body.classList.add("customclass");

Ah, after much google searching I found the relevant information:
https://developers.google.com/search-appliance/documentation/46/admin/URL_patterns#match_ports
So the trick was to wildcard the port rather than state it.
"matches": ["http://subdomain.subdomain.subdomain.edu.au:*/Folder/*"]
This fixes my issue (it doesn't really matter for me which port gets used) but there should be a better way to match urls with a port number so that specific ports (i.e. :82) works.

Related

Chrome Extension not triggered on Google Calendar page (<all_url> in manifest.json)

I'm writing my first Chrome extension and it currently appears to work on all sites that I have tested apart from Google Calendar (which is really where I would like it!)
I've simplified the code as much as possible to try and fix this;
manifest.json:
{
"name": "TestExtension!",
"version": "0.0.1",
"manifest_version": 2,
"description": "Quick Test Extension",
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": ["content.js"]
}
]
}
content.js
console.log("Chrome extension go...");
Working
Not Working
Any ideas? What is different about Google Calendar. It works fine on Gmail and I have tried specifying the Calendar URL specifically as well with the same results.
Many Thanks to wOxxOm - A full Windows restart fixed the issue. (I really should have tried that, still not sure why killing all the Chrome processes didn't work but sorted now)

My extension shows up in Chrome, how can I stop this?

So I am learning how to make chrome extensions. What I am trying to do is only useful at one specific website, so I hoped that I can somehow "hide" the extension when I am not at this website. It seems like Chrome Remote Desktop or Google docs extensions also don't show up next to the adress bar. How can I achieve the same with my extension? Here is my manifest:
{
"name": "Test",
"description" : "I am learning",
"version": "1",
"manifest_version": 2,
"content_scripts": [
{
"matches": ["*://www.google.com/*"],
"js": ["myscript.js"]
}
]
}

Why does my chrome extension ask for history permissions?

In my manifest.json file, I have nothing explicitly listed for reading a user's history, however, this warning comes up when you try to install the extension.
Here is my manifest file:
{
"manifest_version": 2,
"name": "QueueTube for YouTube!",
"short_name": "QueueTube",
"description": "Search YouTube without stopping the video, and make your own playlists!",
"version": "1.5",
"author": "Dara Javaherian",
"permissions": ["tabs", "*://*.youtube.com/*"],
"background": {
"persistent":true,
"scripts": [
"bg/socket.io.js",
"bg/background.js"
]
},
"icons": {
"128": "icons/youtube-128.png"
},
"browser_action": {
"default_icon": "icons/icon.png",
"default_popup": "popup/popup.html"
},
"web_accessible_resources": [
"spinner.gif"
],
"content_scripts" : [{
"matches" :
["https://www.youtube.com/*",
"http://www.youtube.com/*"],
"js" : [
"js/jquery.js",
"js/inject.js"],
"css" : ["styles/styles.css"]
}]
}
Does anyone know why this permission is showing up?
This is the standard warning for the "tabs" permission.
It allows you to query, and be notified of changes, to URLs of all tabs. This allows you to spy on the user's history in real time - even if you don't have access to the browser's own history log.
Note that "tabs" permission is not required in most cases. Providing access to URLs is basically the only reason to include it. You can use most of the tabs API without it, and can get access to current tab without warning using the "activeTab" permission.
Warnings and their triggers
It can be surprising when adding a permission such as "tabs" results
in the seemingly unrelated warning that the extension can access your
browsing activity. The reason for the warning is that although the
chrome.tabs API might be used only to open new tabs, it can also be
used to see the URL that's associated with every newly opened tab
(using their tabs.Tab objects)
Source: https://developer.chrome.com/extensions/permission_warnings

How to link to the extension-affected version of a page from within an iframe?

Let me explain. My chrome extension consists of this:
Injecting an html page in an iframe
Inside this html page is another iframe sourced to an external site
This external site is being modified by the extension also
The problem is I am not seeing the effects I should be. How do I specify I want to display the version of my site affected by the extension?
Edit: Here is the exact part of the code that Im working with:
<iframe id="wikiforum" src="http://mudandblood.net/html/modules.php?name=Forums"></iframe>
That url its currently pointing to is also having css and js injected into it by my extension. Everything works how it should when I visit the site directly, but through the iframe it remains unchanged. Thats what I'm trying to fix.
2nd Edit: Yes, I am injecting the content scripts through the manifest. Like so:
{
"name": "MnB2+",
"version": "1",
"manifest_version": 2,
"content_scripts": [
{
"js": ["contentscript.js"],
"matches": ["http://mudandblood.net/mudandblood2.swf","http://www.mudandblood.net/mudandblood2.swf"],
"all_frames": true
},
{
"css": ["style.css"],
"js": ["csforum.js"],
"matches": ["http://mudandblood.net/html/*"]
}
],
"permissions": [
"tabs"
],
"web_accessible_resources": [
"irc.html",
"wiki.html",
"style.css",
"vectors/*.svg"
]
}
So I'm a dolt and a noob, I solved my own problem. Downvote me as you will, I apologize sincerely. Wouldn't have figured it out though if I didn't post here.
The key was I didn't include "all_frames": true in the second content script section. Hope this at least helps another newbie on the way.

Can I use a chrome extension to add a widget to my website?

I'm playing with chrome extensions, trying to learn how to use them.
Is it possible for me to write an extension which injects a widget into my website whenever someone with the extension visits it? Can you recommend a sample application or tutorial that I can look at, which showcases something like this?
You can only inject JavaScript and CSS through Chrome extensions.
To inject the script or css your manifest.json should look something like this:
{
"name": "Website addon",
"version": "1.0",
"manifest_version": 1,
"description": "Addon for your website",
"content_scripts": [
{
"matches": ["*://yourWebsite.com/*", "*://*.yourWebsite.com/*"],
"js": ["yourJS.js"]
"css": ["yourCSS.css"]
}
]
}
This will add yourJS.js and yourCSS.css to all websites on yourWebsite.com
Here is a link to a tutorial from google: http://code.google.com/chrome/extensions/content_scripts.html

Resources