Can't load ACE editor in a firefox addon, but can in chrome - firefox-addon

I am using ACE editor in my browser extension. It all works fine in a Chrome/Chromium browser, but when I try the extension in Firefox (latest version), only ace.define and ace.require are available (ace.edit is needed, at least, to initialize).
Here is the part of the manifest (MV2) file involved:
"content_scripts" :
[
{
"matches": ["*://example.com/*"],
"all_frames": true,
"js": [
"ace-min/ace.js",
"myscript.js"
],
"run_at": "document_end"
},
]
What could be done wrong? Both files are being read, but only a part of ace.js seems to be executed. Imagine that myscript.js contains a console.log(ace), to see which functions can I use.
Thanks in advance!

I posted an issue on the ACE's GitHub repository. The response was very quick and polite.
All is explained in this comment: https://github.com/ajaxorg/ace/issues/4898#issuecomment-1217887526
Just a side note, use noconflict ace instead of normal ace. The function you need to change is at the bottom.

Related

Commandline to add and exception in edge to allow download and run JNLP

I have the issue I would like to automate via a script so tat .jnlp will be added as an allowable type of file , is there a command like or powershell or regedit that will add it?
The latest file types policies are published in the Chromium source code. You could clearly see that the danger_level of .jnlp type files is DANGEROUS. Therefor Edge will warn users that this file may harm their computers. Let users continue or discard the file.
If you ensure that the content(download file) on the site is safe, you can use this policy to specify the file types that are allowed to be downloaded continuously from a specific site: ExemptDomainFileTypePairsFromFileTypeDownloadWarnings.
Example:
[ { "file_extension": "jnlp", "domains": ["contoso.com"] }, { "file_extension": "exe", "domains": ["contoso.com"] }, { "file_extension": "swf", "domains": ["*"] } ]
If you want to achieve the same function through the registry, you can set it under this path: SOFTWARE\Policies\Microsoft\Edge\ExemptDomainFileTypePairsFromFileTypeDownloadWarnings

Electron: Keep Getting 'You'll need a new app to open this' Screen

Developed an Electron app using Vuejs and everything works fine in development, but when packaged I keep getting this pop-up after start up (NOTE: This is a sample image - mine doesn't say 'windowsdefender' but is otherwise the same).
Using electron-builder to create the application with the following build json, and it is installed on the PC:
{
"productName": "My App",
"appId": "com.mycompany.myapp",
"win": {
"icon": "build/icon.png",
"target": [
"nsis"
]
}
}
Though the app does open, there is no initial screen. However, I can open the dev tools but there are no errors displayed.
Any ideas on what is causing this or how to resolve?
After many tries, I finally figured it out (or at least I think I know what caused the issue).
The primary issue was that in using vue router (from an app ported from the web), it is important that you use 'hash' mode and not 'history. Add this to your router file:
const router = new VueRouter({
mode: process.env.IS_ELECTRON ? "hash" : "history",
routes
});
See this link for more details (common issues): Vue CLI plugin common issues
Second, I think there is a rights issue (i.e. having elevated rights to install) so I added this line along with the guid to my electron-builder.json file. The result was a build file like this:
{
"productName": "My App",
"appId": "com.abcco.my-app",
"win": {
"icon": "build/icon.png",
"target": "nsis",
"requestedExecutionLevel": "requireAdministrator"
},
"nsis": {
"guid": "6ee647a9-d5c6-46a9-a480-aa7d6d3d1c10",
"oneClick": false,
"allowToChangeInstallationDirectory": true
}
}
As I am developing only for Windows I was able to use material from this page (React but not that different with respect to Electron packaging):
Electron Build file help
The last thing I did was to remove all 'dist' files and uninstall the app entirely (previous versions). I think this cleared up a lot of the 'baggage' left over from testing.
Hopefully this helps others who may experience the same issue.

How to add extensions to Microsoft Edge

I an trying to figure out how to add webRequest extension to Microsoft Edge. Can someone provide some assistance? I have gone though a number of documents, but when I go to Microsoft online store I don't see it there.
Test code:
<html>
<script>
browser.webRequest.onBeforeRequest.addListener(
logURL,
{ urls: ["<all_urls>"] }
);
function logURL(requestDetails) {
console.log("Loading: " + requestDetails.url);
};
</script>
</html>
In the doc of webRequest in MDN, we can see that:
To use the webRequest API for a given host, an extension must have the "webRequest" API permissions and the host permission for that host.
Where can we add the permissions? The answer is the manifest.json file. It is the necessary part of an extension. You could see the Anatomy of an extension to learn the compositions of an extension.
Besides, browser.webRequest isn't in the list of content scripts APIs, so we can only use it in background scripts.
In a conclusion, we can't just use the browser.webRequest in a script of a html file. If we want to test the event browser.webRequest.onBeforeRequest, we need to have a manifest.json file, put permisssions in it:
"permissions": [
"*://learn.microsoft.com/*",
"webRequest"
]
Then put the scripts you gave in the background scripts. Then you could try to debug the extension in Edge, there will be no error. Here is an article about creating a Microsoft Edge extension, you could refer to it if you need.

Web Components In firefox extension

I'm trying to use web components inside a Firefox extension but i always get errors trying to add the needed polyfills to make web components work on firefox.
Polyfill using
"webcomponents/webcomponentsjs": "^2.0.3"
First Attempt - webcomponents-sd-ce.js
"content_scripts": [
{
"matches":["<all_urls>"],
"js": ["bundles/webcomponents-sd-ce.js", "contentScript.js"],
"run_at": "document_end"
}
The error i get is
TypeError: "importNode" is read-only webcomponents-sd-ce.js:100:457
Its failing at using the library. The example code i was working with worked on chrome. Chrome needed this polyfill because in the context scripts windows there was no 'customElements' property. Something that is normally default on the user window property list.
Second Attempt - webcomponents-bundle.js
"content_scripts": [
{
"matches":["<all_urls>"],
"js": ["webcomponents-bundle.js", "contentScript.js"],
"run_at": "document_end"
}
The error i get is
TypeError: "importNode" is read-only webcomponents-bundle.js:169:460
I don't normally have problems with these file, so i don't exactly know where the problem originates. If its a problem between the context's window and the normal window or just in how i'm using it.

How do I setup/use ruby on rails snippets and autocomplete in sublime text 2?

I would appreciate if someone could direct me to a website that shows how to do this..
Can't seem to find anything decent enough via google.
This will be the first time I'm doing this kind of thing with a text editor.. It has got to the stage where typing out things like <%= %> is getting old and slow.
I've got a rails snippet package and also ryan-on-rails package installed. Just confused with how to start using them.
I'm on max osx - snow leopard
Kind regards
Update
This helped me out. http://webtempest.com/sublime-text-2-how-to-create-snippets/ but I still need a little practice.
I have a package "rails" can't remember where I got it but the triggering of snippets is working. I'd just like to find a nice list of the commands rather than have to go to each snippet and look for myself. I can find the by clicking on snippets but isn't there a way I can create a shortcut for that?
Also would like some auto indentation.. and also complete.
I'm puzzled that this isn't part of the default Rails package, but I found this to be just what I was looking for:
https://github.com/eddorre/SublimeERB
Since you're new to Sublime Text, I highly recommend you check out: ST2's Unofficial Documentation. If includes a ton of getting started info plus tons of info for extendibility and plugin development.
Another great "Getting Started" guide can be found here on Nettuts+.
If you're looking a list of your snippets and their associated shortcuts, go to "Tools > Snippets..." from your menu.
To expand <% into <%| %> (where | is the cursor), add the following you to your User-keybindings (Preferences > Keybindings - User):
{
"args": {
"contents": "% $0 %>"
},
"command": "insert_snippet",
"context": [
{
"key": "selector",
"match_all": true,
"operand": "source.ruby",
"operator": "equal"
},
{ "key": "preceding_text", "operator": "regex_match", "operand": ".*<", "match_all": true }
],
"keys": [
"%"
]
}
The latest beta includes improved auto-indentation, so if you don't have that installed, try that out.
As for autocompletion, Sublime Text 2 by default offers autocompletion of words in the current document (plus all of your snippets/completions from packages). However, if you're looking for IDE-like autocompletion, there is the SublimeCodeIntel plugin. I am reluctant to mention it because it has not been updated in months and the bug reports keep flowing in.
Hope that helps.
I use ERB Snippets
https://github.com/matthewrobertson/ERB-Sublime-Snippets
You can install via Sublime Package control
Cmd+Shift+P
Go to Package Control: Install Package.
Type ERB Snippets. Let it roll.
Then you can use tab autocomplete for lots of snippets such as:
print ERB tags = pe which auto completes to <%= %>
if block = if which auto completes to <% if %>...<% end %>
If you are looking for autocomplete suggest, change the auto_complete_selector in Preference like:
"auto_complete_selector": "text, source - comment",

Resources