Ok so i am actually interested in building an extension for google chrome and firefox and my friend recommended me KangoFramework since it is cross platform.
So I downloaded ver 1.7.9 of the framework can't actually download ver 1.8.0 due to 404 error on their web or something. So I got to coding my first page with is the login page and I wrote some scripts for it to run and it work! Great !!
And so i wrote another page and I wrote another script and it works on google chrome but in firefox it seems like it didnt load my script at all as the debugger doesn't even show that I have the script file.
so i am confuse by this as how can this happen
here's my extension_info.json
{
"content_scripts": [
"assets/Javascript/LoginPage.js"
],
"description": "Extension description",
"creator": "Annonymous",
"background_scripts": [
"main.js"
],
"homepage_url": "http://kangoextensions.com/",
"version": "0.9.0",
"browser_button": {
"caption": "some Extension",
"icon": "icons/Logo.png",
"tooltipText": "add on"
},
"name": "someExtension"
}
And here's my main.js File
function MyExtension() {
var self = this;
kango.ui.browserButton.addEventListener(kango.ui.browserButton.event.COMMAND, function() {
kango.ui.browserButton.setPopup({url:'Index.html', width: 500, height:500});
});
}
MyExtension.prototype = {
_onCommand: function() {
kango.browser.tabs.create({url: 'http://kangoextensions.com/'});
}
};
var extension = new MyExtension();
and here's my html: http://pastebin.com/REdbhRqu
and here's my HamburgerMenu.js : http://pastebin.com/SvnRkH9Y
and lastly here the PhotoSwipe.js : http://pastebin.com/ykMW13YN
PhotoSipe.js is just to start the plugin
Related
My web extension was working pretty fine a month ago, but now this is not working anymore.
What usually do my addon?
I am injecting a bar on every web page that the user is opening.
What is doing right now?
Nothing; I can install my extension but I don't see my bar on the web pages.
I was not sure if I made an update and broke something so, I am using my first extension version (It was tested and worked fine on the pass) but now this first version does not work too.
I think there are some updates on the browser and something is breaking my extension.
Firefox ESR Version: 52.5.3 (64-bit)
Manifest.json
{
"manifest_version": 2,
"name": "MSC Social Bar",
"version": "1.0",
"description": "MSC Social bar can show you the last news",
"icons": {
"48": "icon/msc.ico",
"98": "icon/msc-x2.ico"
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["./js/vue.js", "./js/msc-scripts.js"],
"css": ["./css/msc-styles.css", "./css/fonts/msc-icons.css", "./css/fonts/msc-fonts.css"]
}
],
"applications": {
"gecko": {
"id": "borderify#example.com"
}
}
}
msc-script.js
(function(){
'use strict';
window.addEventListener('load', function(){
if (window.top === window.self) {
// My code
...........
}
});
}());
Y have made some test and if I remove this line it works nice:
window.addEventListener('load', function(){});
For me is really necessary keep my main skeleton like be.
Could you please help me? There are new updates with this version browser?
I have tested it on this version Firefox Quantum 57.0.1 and it works fine.
Yes #Barmar you are right is not necessary use this
window.addEventListener('load', function(){});
I need to create a Chrome Extension that, among other things, needs to call a native windows app to get some data, particularly IP Address, and a Citrix User ID(it's obviously on Citrix). Currently, I am unable to open the port in the extension, and I am just doing this all locally, on Windows 10, no Citrix.
My manifest file for the listener is:
{
"name": "com.q.userid",
"description": "My Application",
"path": "C:\\Temp\\NativeMessageHost.exe",
"type": "stdio",
"allowed_origins": [
"chrome-extension://mbodcbioidcfdfhjgekeppinibhhnnmh/"
]
}
For the sake of simplicity/testing, my extension uses a browser action, that has a pop up with a text box, and I call my native app in the onKeyUp. My JS for this is as follows:
$(function() {
$('#name').keyup(function(){
var port;
port = chrome.runtime.connectNative('userid');
console.log(port);
port.onMessage.addListener(function(msg) {
console.log('Received: ' + msg);
});
port.onDisconnect.addListener(function() {
console.log("Disconnected");
});
port.postMessage({text: "hello"});
});
});
My Manifest File for the extension is:
{
"manifest_version": 2,
"name": "Hello World",
"description": "Hello World",
"version": "1.1",
"browser_action": {
"default_icon": "icon.png",
"default_title": "Hello World",
"default_popup": "popup.html"
},
"permissions": [
"nativeMessaging"
]
}
When I trigger the code, I get an output of
Port {}
Disconnected
"Disconnected" is immediate.
From the windows task manager, I do not see the exe launching.
In the console of the extension I past in the line
port = chrome.runtime.connectNative('userid');
Then I paste in
port.postMessage({text: "hello"});
That yields an uncaught error: attemting to use a disconnected port.
I added the registry key:
HKEY_CURRENT_USER->SOFTWARE->Google->Chrome->NativeMessagingHosts->com.q.userid
default : c:\temp\manifest.json
I also tried it as
default : c:\temp\manifest.json
the chrome log stated it was unable to find the manifest file for userid
Any thoughts or suggestions?
Thanks in advance.
I know about both common problems that people are having:
If you change the command keys in the manifest file you need to
remove and reinstall it for the changes to take effect.
Even if you do this, you may also need to scroll down on the
extensions page, click the keyboard shortcuts link, and set the
commands manually.
About six months ago, I successfully implemented global keyboard commands with a Chrome Extension on the Chrome OS platform, it seems as though one of their updates has broken this feature... perhaps someone knows of a workaround? With the code below, if you load as an unpacked extension, then scroll down the chrome://extensions page to manually click the "Keyboard Shortcuts" and assign the command, you will see that you have the option to set it to run in either Chrome or Global... Chrome works, but if you assign Global, nothing happens (both inside Chrome and outside when using the file system or apps)... any ideas?
background.js
chrome.commands.onCommand.addListener(function(command) {
if (command == "toggleHighContrast") {
chrome.accessibilityFeatures.highContrast.get({},function (callback){
var value = true;
if (callback.value) value = false;
chrome.accessibilityFeatures.highContrast.set({value:value});
});
}//Ctrl+Shift+A
});
manifest.json
{
"manifest_version": 2,
"name": "High Contrast",
"short_name": "contrast",
"description": "",
"version": "0.0.1",
"minimum_chrome_version": "38",
"offline_enabled": true,
"commands": {
"toggleHighContrast": {
"global":true,
"description": "Toggle High Contrast Mode"
}
},
"background": {
"scripts": ["background.js"],
"persistent": true
},
"permissions": [
"accessibilityFeatures.read",
"accessibilityFeatures.modify"
]
}
I'm updating one of my chrome apps to just launch the web app (why? I don't have the time to continue updating the chrome app, alone with the desktop apps for offline use)
Here's what the manifests starts with...
"app": {
"background": {
"scripts": [ "background.js" ]
}
},
I just want it to open a new tab to the website now instead of launching a packaged app. So I tried the following...
"app": {
"launch": {
"web_url": "http://stackoverflow.com/"
}
},
An error occurred: Failed to process your item.
Please specify background subsection of app section in the manifest.
"app": {
"launch": {
"web_url": "http://stackoverflow.com/"
},
"background": {
"scripts": [ "background.js" ]
}
},
An error occurred: Failed to process your item.
Application specifications for packaged and hosted apps are incompatible. Please refer to manifest specification.
The manifest may not contain a launch object inside the app object.
So I decided to stick with just the background script and try to just create a new tab that way.
background.js
chrome.app.runtime.onLaunched.addListener(function(launchData) {
chrome.app.window.create(
'index.html',
{
id: 'mainWindow',
innerBounds: {
'width': 800,
'height': 600
}
}
);
});
index.html
<script>
var a = document.createElement("a")
a.href = "http://stackoverflow.com/"
a.target = "_blank"
document.body.appendChild(a)
a.click()
</script>
I was finally able to successfully add a new tab with...
chrome.app.runtime.onLaunched.addListener(function(launchData) {
window.open("http://stackoverflow.com/")
})
in my background.js script.
However the following error occurs...
I clicked on the "Learn More" button but that too gave me the same "Aw, Snap!" page
Does anyone know why I can't open a new tab in a chrome packaged app?
and
How am I suppose to open a new tab in a chrome packaged app?
Use chrome.browser.openTab({ url: "" }, callback) with the "browser" permission.
https://developer.chrome.com/apps/browser#method-openTab
I'm trying to build my first Chrome extension but I found problems with debugging.
I'm able to console.log() but in the Developer Tools console (I'm working on the background.js; no UI) there's no report about syntax errors.
Is that normal? Or it depends on some settings of the page I'm creating the extension for? (www.google.com)
I've read maybe there could be a window.onerror set somewhere but I'm not able to find it. I tried a
window.onerror = null;
at the beginning of the background.js but nothing has changed.
What would you do to get the errors back?
UPDATE (Adding code)
This is the manifest.json:
{
"name": "Name",
"description": "Description",
"version": "0.1",
"manifest_version": 2,
"background": {
"persistent": false,
"scripts": ["js/background.js"]
},
"permissions" : [
"tabs",
"*://www.google.com/*",
"*://www.google.de/*"
],
"commands": {
"changeSearch": {
"suggested_key": {
"default": "Ctrl+Shift+A",
"mac": "Command+Shift+A"
},
"description": "Change."
}
}
}
The background.js start like this:
console.log("Start");
chrome.commands.onCommand.addListener(function(command) {
consTYPOTYPOTYPOTYPOTYPOTYPOle.log("catched");
...
I just discovered that errors are thrown if the TYPO is otuside of function(command) code, if I have TYPOs on the 1st or 2nd line.
The 3rd line is totally silent. No error. It just doesn't work.
That's weird to me!
The problem was a conflicting extension that was overriding mine.
Trying to disable all extensions and then re-enabling them, starting from mine, solved the problem.
Probably I made it to have higher priority respect to the conflicting extension (that has been enabled after).