I'm attempting to use URI.js with the Firefox Addon SDK.
I've include the URI.js file (built from https://medialize.github.io/URI.js/build.html) in my Addon SDK index.js file - but I keep getting the following error:
Module ./punycode is not found at resource://uw-cashback-wizard/punycode.js
As a workaround, I thought I might use a worker, but workers only allow async messaging, and I'm trying to use it as part of synchronous methods.
Related
I am trying to build a chrome extension that uses firebase as a db in my content.js file but it doesn't work. I am using v3 manifest. But I am unable to import firebase.
I tried setting up firebase in my project using this resource. I also tried downloading the source code from firebase-app.js and firebase-database.js, and imported it using
const firebase = chrome.extension.getURL('./firebase-app.js');
but this file has imports from
https://www.gstatic.com/firebasejs/9.15.0/firebase-app.js
this violates the content_security_policy and I get this error
Refused to load the script ‘https://www.gstatic.com/firebasejs/9.15.0/firebase-app.js’ because it violates the following Content Security Policy directive: “script-src ‘self’ ‘wasm-unsafe-eval’“. Note that ‘script-src-elem’ was not explicitly set, so ‘script-src’ is used as a fallback.
I am aware of the external code restrictions.
Is there any workaround for this in vanilla JS implementation?
As the ECRs state, you cannot load these scripts from a CDN.
Instead you must install a JavaScript build pipeline (such as webpack or Rollup) to compile an application bundle of your extension's code.
Firebase has documentation on this process and link to relevant resources that are worth reviewing.
I searched whole stackoverflow to fix it, but cant. So... I need to use NPM module in browser (index.html).
Getting error "require is not defined" if using
<script src="./script.js"></script>
in html file, and using const { WebcastPushConnection } = require('tiktok-livestream-chat-connector'); in script.js.
Tried to use browserify, and when i use outputed js script getting error "require.resolve is not a function"
Can anyone help?
tiktok-livestream-chat-connector is described, by its website, as:
A Node.js module to receive and decode livestream events like comments and gifts in realtime from TikTok LIVE by connecting to TikTok's internal WebCast push service.
At no point in its documentation does it mention compatibility with web browsers.
Browserify (and similar tools) can bundle up CommonJS modules into a single file so that they can run in environments which don't support CommonJS modules (e.g. browsers). They can't polyfill all the Node.js features that browsers don't support (like the ability to make raw socket network connections).
If a module needs to run on Node.js then you can't just move it to the browser.
You could write a program for Node.js that runs as a web service and operates as a bridge to whatever the module does. The the browser could connect to your web service with WebSockets or Ajax requests. The project links to an example of one.
I recently started working on a chrome extension project.
I need to consume some third party libraries and I am planning on adding their minified version to my project.
In node.js there is a loading mechanism that allow me to import any package in node_module without adding that path to the node_module.
I'm trying to mimic this behavior in my extension. My question is how to do it? I've read and investigated plenty in MDN and many other site but the only reference I found for this use case was in Typescript and in Webpack, which I cannot use in this project.
I am trying to run a JSC (https://github.com/facebook/android-jsc) on an Android app. I can't find any API to use it with. Can you guide me to any resource?
Using gradle
implementation 'org.webkit:android-jsc:r174650'
But if you download aar file e.g. http://central.maven.org/maven2/org/webkit/android-jsc/r174650/android-jsc-r174650.aar Then classes.jar will be empty in it. There are avaliable only jni binaries
I found a library on github that I would like to use but the download instructions only mention using npm but I am not using a NodeJS project (just a basic html,css,javascript front-end with no back-end server). Am I still able to use that library or is it a lost cause? Is there another way to download it without using npm?
Is there another way to download it without using npm?
If it's on github, then you can checkout or fork the repository as you can with any other git repo.
Am I still able to use that library or is it a lost cause?
Whether or not the library will work without Node will depend on the library.
If it presents itself as a Node module, then you'll probably have to modify it (or find a compatible module loader for browser-side JS).
If it depends on NodeJS features (such as the filesystem API) then you'll be out of luck (unless, for example, you polyfill them to work across HTTP)
If you use a build tool such as browserify, or webpack, you can author scripts that require node modules and the build tool will generate a script that includes all the necessary dependencies (assuming that the necessary dependencies are compatible with client-side JavaScript environments).
Downloading dependencies would still be done via npm, but only for local development. Your server would only need the generated script.
Alternatively, if the script is on github or any other repo online you may be able to download it directly. Many modules are published using UMD, which would allow you to use the script using various inclusion methods.