Editing pure JavaScript extensions directly in Chromium - javascript

I'm developing a JavaScript extension for Chromium and my current workflow is:
Edit file
Uninstall old file
Install new file
Test file
Is there a quicker way of doing this?
I'm using chromium-browser_5.0.375.125 in Ubuntu 10.04.

Load your extension into Chromium
Find your extension's ID:
Go to the extensions page chrome://extensions/
Click + Developer Mode
Scroll down to your extension and look at the ID: field
Open ~/.config/chromium/Default/Extensions/ID/VERSION/script.js in a text editor
Now simply edit, save, and test
For a pure JavaScript extension the version number should be 1.0.

Related

How to test firefox plugin locally

I have a basic Google Chrome extension which needs to be ported to Firefox. I uploaded the .crx file to the Firefox marketplace and it got accepted but is under review rightnow. I downloaded the the generated xpi file and tried to install it locally but without any success. It tell that the plugin is invalid or corrupted.
Another method that I tried is I ported the extension using chrome-tailor and generated the xpi. I am able to install the extension in this but the content scripts are not injected and the extension doesn't work as expected.
I want to install it in Firefox and test it. I have also set xpinstall.signatures.required to false.
WebExtensions
To test WebExtension based add-ons, they are usually loaded as a "Temporary Installation in Firefox"
That MDN page describes how to temporarily install a WebExtensions (i.e. similar code to Chrome) in Firefox. The gist of it is:
Navigate to about:debugging
Click the button "Load Temporary Add-on"
Use the file selection dialog to select the manifest.json file, or packaged .xpi file for the extension.
Note on testing WebExtensions:
The WebExtensions API is still in development. For now, you are probably best off developing and testing your WebExtension add-on with Firefox Developer Edition, or Firefox Nightly. You should also make careful note of what version of Firefox is required for the functionality you desire to use. This information is contained in the "Browser compatibility" section of the MDN documentation pages.
Firefox Add-on SDK
To test Firefox Add-on SDK based ad-ons, use jpm run. You might want to take a look at this answer to "jpm run does NOT work with Firefox 48, or later"

How to debug an AngularJS app using sublime text and Live Reload

I'm developing an AngularJS app, and would like to use Sublime Text in combination with Live Reload to do my debugging. I was using WebStorm before, where I could just select my index.html, and right-click -> debug.
How do I achieve the same functionality using ST with Live Reload?
First - what tool or process do I use on my Mac, to serve my index.html to my Chrome browser?
The goal is to be able to edit a given html or JS file in ST, and have Chrom auto reload when the edited file is saved.
WebStorm debugs both PHP and JS at the same time, if i'm not mistaken.
But since AngularJS is javascript, you could just use the google chrome developer tools or Firefox's firebug.

JavaScript Injection using Firefox Mobile

I would like to inject JavaScript into a website on a mobile browser (in this case on android). However, most mobile browsers do not seem to support any kind of plug-ins (except for Firefox, correct me if I am wrong).
Firefox support for mobile plugin development seems to be minimal too, for example one can not install xpi-files by downloading them (I have yet to find out how one can install a plugin that is not hosted on the add-ons for android site)
Why not use existing solutions?
The best way to inject javscript would be Greasemonkey but this is not supported on mobile. Scriptish supposedly is but I could not install it on any device. There are android browsers specifically written to support Greasemonkey scripts (Fat Ape or Tampermonkey or OilCan) but these are not used by many and while they enable JavaScript injection the lack in their support for other browser-features.
What exactly is my question?
My experience in Firefox-Plugin development is minimal so I would like to know: Is there something that would prevent something like this to run on FF-Mobile? Could it be done with other browsers too? I don't actually need the full power of Greasemonkey, injecting the same few lines into any website would probably do.
Update 2
This again needs updating!
The new Firefox (current 95.2) no longer supports this method! But the old version still does! You will have to DL an old version (let's say 68.7). You can get it on ApkMirror. Then to install Greasmonkey either google it and choose the Mozilla page or just visit this link. On that page choose to download the file. When the XPI file will be downloaded it will automatically request to install it and that's it. You now have Greasemonkey installed on your Android device!
Be advised that this is an old unsupported Firefox version full of security holes!
Update
This needed updating!
The new Firefox now has full support for Greasemonkey add-on!
Instructions:
Find and install Firefox on the play store.
Run it and from the menu choose Add-ons and install your favorite add-ons like the ad blocker uBlock origin. Use the search and input Greasemonkey and install it.
Profit! :)
Old
If you want full Greasemonkey with even cross domain / cross site
GM_xmlhttpRequest support then your only option right now is: Opera
Mobile Labs (with Extensions) (link to APK is on that site).
Run Opera Mobile Labs app and visit Violent Monkey's extension
site and install the 1.5.1.1 (OEX version) by clicking on "Add to
Opera" and then choose "OK" (maybe you'll have to restart Opera
Mobile for the extension to work.).
To install an userscript you just need to load it in the browser by
visiting the user.js URL location. If you have userscripts on your
SD card, you can load them thru entering "file://" into the address
bar and navigate to your user.js files and then choose "OK".
If you have a bunch of normal scripts (no GM_ functions) then you
could also use this instructions (it's faster!):
Save your user.js scripts in a folder on your SD card (eg. "/sdcard/js").
Run Opera Mobile app and enter "opera:config" into the address bar and then in the "Quick find" input enter "javascript". Go
down and under "User Prefs" tick the following: "Always Load User
Javascript" and "User Javascript". Under "User Javascript File"
enter the path to the folder with your user.js files (eg.
"/sdcard/js").
At the end don't forget to tap "Save" otherwise your setting will not be saved! Restart Opera!
If you don't want to download the APK file then this second method
also works with Opera Mobile Classic. You can find the app in the
Play Store.
If you can install Google Chrome (Android > 4.0) on your mobile phone you can do remote debugging.
Overview of Google Chrome for mobiles :https://developers.google.com/chrome/mobile/docs/overview
Overview of Remote Debugging: https://developers.google.com/chrome-developer-tools/docs/remote-debugging
Another option for running Userscripts on mobile devices is the Tampermonkey userscript manager.
There are Tampermonkey add-ons for both the Dolphin and UC Android browsers.
Tampermonkey add-on for the Dolphin Web Browser:
https://play.google.com/store/apps/details?id=net.tampermonkey.dolphin
Tampermonkey add-on for the UC Web Browser
https://play.google.com/store/apps/details?id=net.tampermonkey.uc
To use them you first need to have the respective browser installed.

How To Open PDF Files Inside Chromium?

I'm using nodejs and chromium for my desktop app. The problem is that I can't open pdf files in chromium. So I googled and found that most of the answers are related to mozplugger plugin. I installed the plugin as mentioned in the below link:
http://www.tootips.com/2013/01/how-to-open-pdf-files-inside-chromium.html
Now I'm getting an error message : "Mozplugger: M4 parsing of config generated error" when I try to open pdf file in chromium. How can I resolve this error?
Please help me!
If you look at this Ask Ubunutu question you'll see you can actually use Chrome's PDF viewer with Chromium.
Chrome has a nice PDF plugin that lets you open in the page, but it's not open source so it's not included with Chromium. You could install Chrome and symlink the plugin, then whenever you update Chrome you would also get that updated in Chromium. Alternatively, you could copy the plugin over to Chromium, and uninstall Chrome, but you won't receive updates that way.
Have you tried using PDFjs as a totally javascript based alternative solution?
https://github.com/mozilla/pdf.js
It is relatively new but works on many different examples, maybe it is good enough for your application.
In Linux I think we need mozplugger plugin for viewing pdf files. I just removed and installed mozplugger again (Reference links: http://www.tootips.com/2013/01/how-to-open-pdf-files-inside-chromium.html, http://mozplugger.mozdev.org/ ) and now it seems to work.
In windows we need to install a system pdf reader like acrobat (http://www.adobe.com/in/products/reader.html), as chromium downloads and displays pdf with system PDF viewer (Reference link: http://code.google.com/p/chromium/wiki/ChromiumBrowserVsGoogleChrome).
An alternative solution is to open the pdf link in default browser with help of node.js using below script.
Install the node.js open module:
$ npm install open
use:
var open = require('open');
open('http://www.google.com', function (err) {
if (err) throw err;
console.log('The user closed the browser');
});
Reference link: How to use nodejs to open default browser and navigate to a specific URL
You can use this extension by Google: ExtensionDocs PDF/PowerPoint Viewer which also allows you to open docx, ppt, rar and many more file types.
Google recently announced that Google Chrome PDF Viewer goes to open source. It means that in near future Chromium browser and Chromium OS users can soon enjoy the Chrome PDF viewer, without any workarounds!
See PDFium project web page at https://code.google.com/p/pdfium/

How do I check in Firefox and Chrome if a plugin is installed

I'm using an embedded plugin in my web app to enable scanning (Dynamsoft's webscanning plugin). I'm serving an xpi to firefox users and a crx to chrome users. When viewing the page without the plugin installed, Firefox will try to download the plugin and the user will need to click "manual install" to install it. Chrome will make no attempt to donwload the plugin (this is by design, according to http://code.google.com/p/chromium/issues/detail?id=15745)
I would like to use javascript to detect wether the plugin is installed or not (preferrably before trying to load it through the embed tag). If no plugin is installed, I want to provide an explanation and a link to the correct plugin to the user. Both browsers install their respective plugins without any problem if the user clicks at a download link instead of just trying to load through the embed tag.
So, does anybody know a way detect wether a plugin is installed using javascript?
Have you had a look at window.navigator.plugins?
..and the equivalent reference for webkit plugins-
The Apple reference for the WebKit DOM appears to have disappeared. navigator.plugins does work for me in Safari & Chrome. See a jsfiddle here: http://jsfiddle.net/2EaKD/
Sounds to me like a potential security hole, if a website (something remotely) could access your plug-ins (something locally). So I guess this is not possible.
Your addon can monitor which pages are opened by the user. If it is your page, you can make your addon set a global variable in that page and your page's JavaScript should be able to detect this.

Categories

Resources