Can't install my custom chrome extension crx_magic_number_invalid - google-chrome

I made a simple chrome extension:
manifest.json:
{
"name": "Layout VS Design",
"version": "1",
"description": "Enter the url of a image with your design at 100%",
"background_page": "index.html",
"browser_action": {
"name": "Manipulate DOM",
"icons": ["icon.png"],
"default_icon": "icon.png"
},
"content_scripts": [ {
"js": [ "jquery.min.js", "js.js" ],
"matches": [ "http://*/*", "https://*/*"]
}]
}
The thing is that chrome won't let me install it:
The thing is I have no idea where to set this number, Any idea what can I try?

The first thing I see is that your background_page isn't formatted properly. It should be
{ ...
"background": {
"page": "index.html"
},
...
}
If you manifest.json file isn't formatted correctly, Chrome will reject the extension.
You can read more about the manifest formatting in the Manifest File Format documentation from Google.
Update
Another SO post detailed how Chrome looks for a "magic number" at the top of a .crx file. But, if you're hosting locally, you can install extensions in a simpler manner.
Save your manifest.json and background.html to a directory (the name doesn't matter)
Go to chrome:extensions
Make sure "Developer Mode" is checked at the top
Click "Load unpacked extension..."
Select the directory with your background and manifest files to install on Chrome.

go to extensions page
check developer options
click on pack extension
set root directory (folder in which your images and manifest file
exist)
pack extension
now disable developer options
go to root directory (do not open root directory saying this only so
that you could easily find file otherwise you can open it)
you will see a .crx file just open it with chrome (e.g. drag and drop this file onto the chrome://extensions/ page)
click on continue (will come at the bottom of chrome window)
Your Chrome browser is modified like you wanted

Related

How to restrict some url in chrome packaged app

I want to restrict some urls in a chrome packaged app, but when I try to use chrome.webRequest.onBeforeRequest.addListener in background.js in order to detect the call, I get error upon installing the app, 'webRequest' is only allowed for extensions and legacy packaged apps, but this is a packaged app."
My manifest is as below
...
"manifest_version": 2,
"app": {
"background": {
"scripts": ["background.js", "js/chromeUtility.js","js/customchromeserver/wsc-chrome.js"],
"persistent": false
}
},
"permissions": [
"webRequest",
"webRequestBlocking",
"*://www.xyz.com/*", // want to block this url
"identity",
"storage",
"webview",
...
How do I restrict a url in my chrome app , any suggestions ? Thanks
I could finaly do it since the url I want to block is loaded via webview, therefore I have checked it by using webview event listener for new window something like - webview.addEventListener('newwindow'), )

Visual Studio Code debugger with Chrome refused to connect to localhost

I've tried several suggestions on other posts to no avail.
I have a 9 month old project that no longer shows in the browser from F5 debugging in vs code.
I set up a brand new simple project with an index.html file to try to get Visual Studio code to launch it in a Chrome browser window.
I keep getting an error page in chrome that says:
This site can’t be reached
localhost refused to connect.
Did you mean http://localhost8000.com/?
Search Google for localhost 8000
ERR_CONNECTION_REFUSED
launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8000",
"webRoot": "${workspaceFolder}"
}
]
}
index.html:
hello world!!!!!
Any help would be greatly appreciated!
If anyone else is having this issue, I solved it by:
1)installing the ritwickdey/vscode-live-server available here:
vscode-live-server link
2) restarting vscode
3) clicking the Go Live button at the bottom of the screen
4) getting the server address from the resulting Chrome window (ex: http://localhost:5500/)
5) changing the .vscode/launch.json file to include that server address:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:5500",
"webRoot": "${workspaceRoot}"
}
]
}
6) creating(or editing) a settings.json file with the following json:
{
"liveServer.settings.port": 5500,
"liveServer.settings.CustomBrowser" : "chrome",
"liveServer.settings.AdvanceCustomBrowserCmdLine": "chrome --incognito --remote-debugging-port=9222",
"liveServer.settings.NoBrowser" : false,
"liveServer.settings.ignoreFiles" : [
".vscode/**",
"**/*.scss",
"**/*.sass"
]
}
7) switching to vscode's debug pane on the left and pushing the green arrow next to "Launch Chrome against localhost"
Hope this helps someone else out!
For others using VS code to debug Vue it could be as simple as this:
You must have your project running before you start debugging. Contrary to what a user would think, clicking the play button doesn't start your project. It just starts the debugger. The solution for me (using yarn) was running "yarn serve" before starting the debugger. Maybe this is obvious!
If you don't have a web server,You can just change the option "webroot" to "file", and remove the "url" option, like this:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"file": "${workspaceRoot}/index.html"
}
]
}
For someone wants debug react-app like me.
After config as question above.
Pls note: Ensure that your development server is running ("npm start")..
And then F5 to debugg.
It works with my case.
For me I used the code below the installed a chrome extension for javascript and it worked out fine
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"file": "${workspaceRoot}/index.html"
}
]
}
I use laragon for windows to host my websites locally. For myself I just needed to change the URL to the laragon url and it worked fine
For me, the problem was that the debugger configuration had been reset to launch with Chrome. I switched it to .NET Core Launch and then it worked.
I use chrome developer edition, this is the configuration that worked for me:
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "${workspaceFolder}/index.html",
"runtimeExecutable": "YOUR PATH TO THE EXE"
}
]
}
I used the advice of #tuchunxiao, but using the file as url.
Note that this works for experimental JS, but for react, vue, or a production enviroment this is likely not to suit you.
I opened the .htm file with the Live Server and it worked fine.
Right-click on the file (index.htm in my case)
Choose Open With Live
Server
Delete launch.json visible on Explorer tab. Then F5.
I solved my problem just by copying and pasting my browser URL into the URL section in the config file which has the value "local host blah blah"
and it worked.
I use the same live server as you.
I right clicked on my HTML page and clicked on "open with live server option", when the page loaded I copied the URL into the section I mentioned.
Thanks
I believe the error that I introduced was unmindfully creating a launch.json file under .vscode/launch.json, with the below default configurations (w/o making head or tail of it)
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Open index.html",
"file": "c:\\path\\to\\index.html"
}
]
}
Upon removing the file, I could Start Debugging (F5) index.html on my browser
I change the webRoot and url like this and it works
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost/svg/",
"webRoot": "/"
}
For me I just did a simple solution and It worked perefectly.
First, I installed a Live Server by Ritwick Dey.
Select your workspace folder and Go live from the button located at Bottom Right corner.
As you must tried running You must see a .vscode Folder in your workspace or in your rootfolder.
Just **Delete .vscode where you would see a .json file located ** and Restart your Visual Studio Code.
I hope, it works out for you as it did for me.

Why do I get "Unsupported extensions disabled" on my extension?

I did a Chrome extension, successfully published it on Chrome Webstore, a friend installed it yesterday, and today, when launching Chrome, he sees Unsupported extensions disabled:
What are the usual reasons for that? How to fix it?
Note: the extension is just a minimalist:
{
"name": "...",
"version": "1.0",
"description": "...",
"content_scripts": [
{
"css": ["fix.css"],
"matches": ["http://*/*", "https://*/*"],
"run_at": "document_end"
}
],
"manifest_version": 2,
"permissions": ["*://*/*"]
}
and a fix.css that modifies the design of certain elements. Nothing else is in the extension. It is still accepted/published on the Chrome Webstore.
This is because extension is not published in Chrome webstore. Perhaps installing Chromium browser can help. It should allow to use non-webstore extensions.
There is also bit complexated way to use pre-installed extension described here.
As recommended in this page:
Try this removal procedure ... http://malwaretips.com/blogs/remove-discount-buddy-virus/
Try running the new Google Software Removal Tool ..(Windows Only). Do Browser Reset at end.
You may also check this Important: Updates on Chrome Extensions.

Kiosk mode in Node-webkit not working?

I'm trying out the basic tutorial for Node-webkit.
The manifest includes options to make your app go fullscreen or even in kiosk mode, which is exactly what I need.
Sadly, the app does not open in fullscreen or kiosk mode no matter what I put in the manifest file.
I'm on Mac OS, I downloaded "node-webkit.app". I am compressing my manifest.json and index.html into a "app.nw" zipfile, and then opening that with the mac app. Is there anything I'm overlooking?
My manifest file:
{
"name": "mydemo",
"main": "index.html",
"window": {
"title": "baby's first node-webkit demo",
"resizable":"false",
"show_in_taskbar":"true",
"fullscreen":"true",
"kiosk":"true"
}
}
OK, so I'm answering my own question here... don't use:
"kiosk":"true"
Instead use
"kiosk":true
I was under the impression JSON always uses quotes around properties...

Chrome Extension to Set Local Homepage?

Since it seems none exist, I'm trying to make a chrome extension to set my New Tab page to a local .html file. Here's what I have so far:
{
"name": "MyHomepage",
"version": "1.0",
"manifest_version": 2,
"description": "Set an HTML page as your New Tab page",
"browser_action": {
"default_icon": "icon.png"
},
"chrome_url_overrides" : {
"newtab": "/Users/shortname/Documents/Home.html"
}
}
However, when I load a new page, it gives me this:
No webpage was found for the web address: chrome-extension://(gibberish)//Users/shortname/Documents/Home.html
It seems Chrome is sandboxing my extension somehow. Is there a way to let it access my local file?
Chrome's extension API does not allow for direct reading or writing from/to disk.
If you want to do that you'll have to use a NPAPI plugin in your extension:
http://code.google.com/chrome/extensions/npapi.html
You can use Native Messaging instead of NPAPI https://developer.chrome.com/extensions/messaging#native-messaging