I have developed my add-on in scratchpad environment and now developing is finished and I want to create final xpi file.
I replace only this:
Cu.import('resource://gre/modules/ctypes.jsm');
by this:
var {Cu} = require("chrome");
var{ctypes} = Cu.import("resource://gre/modules/ctypes.jsm", null);
Then using nodejs (jpm init and jpm xpi commands) I created xpi file however this is not worked properly.
What we did was follow the jpm tutorial: https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29 and https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm#Installation
I did this on a Windows system:
we downloaded node.js
npm came with it
created a directory, in this directory i did jpm-init from command line
filled out the prompts then filled in the code for the addon:
We then created a similiar addon to this demo addon here:
https://github.com/Noitidart/jpm-chromeworker
I cant share the actuall addon as that was personal to the user. But the above is simpler and shows how to do it.
We did our jsctypes in a chromeworker, and have it communicate with index.js via messaging
Related
I am trying to deploy a shiny app and am running into trouble...
I have an Rmd file, and am trying to publish this document first by running locally in Rstudio, then on web.
My files are stored on my home user directory in a folder named Shiny. This has the files imported, my RMD, my shinyapps.io file, and my rsconnect file.
title: "Sedentary Analysis"
author: "Bianca Gonzalez"
date: "July 26, 2016"
output: html_document
runtime: shiny
When I run the rsconnect::deployApp('SedentaryAnalysis.Rmd') file I get: Document successfully deployed to https://biancagonzalez.shinyapps.io/SedentaryAnalysis/
However when I open my link, I get the error:
/home/shiny/SedentaryAnalysis does not exist.
Thanks for helping me understand this error.
Bianca G
When you call rsconnect::deployApp('SedentaryAnalysis.Rmd'), it only deploys that one file (SedentaryAnalysis.Rmd). Your .Rmd probably has code in it that refers to other files. Those files need to be deployed too for your code to work on shinyapps.io. Here is what you need to do:
Replace any absolute paths in your document with relative ones.
Call rsconnect::deployDoc(...) instead of rsconnect::deployApp(...). This will tell RStudio to look for the files you use in the document and deploy them with the document.
If you're using RStudio, its Publish button will do most of this for you, so try clicking that in the toolbar.
I am developing a Firefox Add-On through CFX tool but while i am using cfx.xpi the Addon xpi is not having other Javascripts files which i am using as a thread ( using Worker ).
I am using :
var twrite = new Worker("t_write.js");
t_write.js is my worker file. But while executing it like this it is giving an Error: Malformed script URI:t_write.js
Please help me by letting me know how to include those files in the add-on package and what is this Malformed Scipt Error
I've tried to follow these steps to get venkman in my xul application:
Get Venkman from addons.mozilla.org To download the package, right-click the install link and save the package locally. (got the newest version).
Create a directory /distribution/bundles/venkman. Unzip the package into that directory.
Add <script src="chrome://venkman/content/venkman-overlay.js" /> to one of your XUL windows.
Add UI to open Venkman to your window (it could be a menu item or a toolbar button). Make it call start_venkman() when activated.
Not sure where to create the distribution directory, I've tried in the same directory as my application.ini in chrome and in chrome/content but when I try to include the script as in step 3 I get:
No chrome package registered for chrome://venkman/content/venkman-overlay.js
And step 4 gives me:
Error: ReferenceError: start_venkman is not defined
I start my application using the following command:
firefox.exe --app application.ini -jsconsole
Changed the BuildID in my application.ini a couple of times but that didn't change anything.
Created the directory: C:\Program Files (x86)\Mozilla Firefox\distribution\bundles and copied the venkman directory in there.
In my xul window I added:
<script src="test.js" />
<button label="Press Me"
oncommand="start_venkman();"/>
The content of test.js is:
function toOpenWindowByType(inType, uri) {
var winopts = "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar";
window.open(uri, "_blank", winopts);
}
When I click the button the Venkman window opens.
I develop Firefox extension with bundled executable file which should be run on browser startup.
To run process I need get nsIFile or nsILocalFile instance which points to executable file.
I know one solution how to get it using directory service:
var file = Components.classes["#mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);
file.append("extensions");
file.append("<extension id>");
file.append("<relative path>");
But this solution has two disadvantages:
It doesn't work in development mode, when instead of installed extension I have only text file with real extension path
I'm not sure that it will work on all Firefox configurations because of hardcoded "extensions" part of the path
So is there any nicer way to run executable file which comes with Firefox extension?
Thanks.
You are making way too many assumptions about the directory structure of the Firefox profile - don't. The Add-on Manager API lets you get the path of a file inside the extension, you should use it:
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID("<extension id>", function(addon)
{
var uri = addon.getResourceURI("<relative path>");
var file = uri.QueryInterface(Components.interfaces.nsIFileURL).file;
...
});
A restartless addon's startup function (in the bootstrap.js file) will receive, as its first parameter, the path where the addon is installed. You can then play various tricks to read files inside the .jar file, if any: see https://github.com/protz/GMail-Conversation-View/blob/master/bootstrap.js#L55 as an example.
In a non-restartless case, I must confess I don't have much of an idea :).
I found this thread looking for a way to reference a path to an image hosted in extension's directory from a content script. Here's a solution:
Include your files in web_accessible_resources in the extension's manifest.
"web_accessible_resources": [
"images/*"
]
Absolute paths to these resources contain randomly generated UUID, therefore we're using runtime.getUrl() giving it the path relative to manifest.json. Example:
let myImg = document.createElement('img');
myImg.src = browser.runtime.getURL("images/my-img.png")
This question already has answers here:
How to use nodejs to open default browser and navigate to a specific URL
(8 answers)
Closed last month.
I don't know if it matters, but I am on OSX.
I know you can launch a browser from the command line itself by typing:
open http://www.stackoverflow.com
But is there a way to open a browser from inside a nodejs command line script?
Open exists now, use that. :)
Install with:
$ npm install --save open
Use with:
const open = require('open');
// Opens the image in the default image viewer
(async () => {
await open('unicorn.png', {wait: true});
console.log('The image viewer app closed');
// Opens the url in the default browser
await open('https://sindresorhus.com');
// Specify the app to open in
await open('https://sindresorhus.com', {app: 'firefox'});
// Specify app arguments
await open('https://sindresorhus.com', {app: ['google chrome', '--incognito']});
})();
The app: ... option:
Type: string | string[]
Specify the app to open the target with, or an array with the app and
app arguments.
The app name is platform dependent. Don't hard code it in reusable
modules. For example, Chrome is google chrome on macOS, google-chrome
on Linux and chrome on Windows.
You may also pass in the app's full path. For example on WSL, this can
be /mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe for
the Windows installation of Chrome.
Example:
open('http://localhost', {app: "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"});