\input texinfo @c -*-texinfo-*- @c %**start of header @setfilename librejsxul.info @include version.texi @settitle GNU LibreJSXUL @value{VERSION} @copying This manual is for GNU LibreJSXUL (version @value{VERSION}, @value{UPDATED}), a Iceweasel-UXP extension to detect and block nonfree nontrivial JavaScript on webpages. Copyright @copyright{} 2011 2012 2014 2015 Loic J. Duros @quotation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled ``GNU Free Documentation License''. @end quotation @end copying @dircategory GNUzilla @direntry * LibreJSXUL: (librejsxul). Detect nonfree nontrivial in Iceweasel-UXP @end direntry @titlepage @title GNU LibreJSXUL @subtitle for version @value{VERSION}, @value{UPDATED} @author Loic J. Duros (@email{librejs@@lduros.net}) @page @vskip 0pt plus 1filll @insertcopying @end titlepage @contents @node Top @top LibreJSXUL This manual is for GNU LibreJSXUL (version @value{VERSION}, @value{UPDATED}). @menu * Overview:: General purpose and information. * Disclaimer:: Emphasize what LibreJSXUL does and does not. * Installation:: Installing LibreJSXUL from source. * How to Use:: How to use LibreJSXUL in Iceweasel-UXP. * JavaScript Detection:: How LibreJSXUL detects nontrivial Javascript. * Free Licenses Detection:: List of licenses detected by LibreJSXUL. * Setting Your JavaScript Free:: Information for website owners/maintainers. * LibreJSXUL Development Notes:: Documentation about the development of LibreJSXUL itself. * Installation Requirements:: Requirements to build and install LibreJSXUL. * LibreJSXUL Internals:: How LibreJSXUL works under the hood. * Tests:: Test LibreJSXUL and better understand it. * GNU Free Documentation License:: Copying and sharing this documentation. @end menu @node Overview @chapter Overview @cindex overview GNU LibreJSXUL ---an add-on for Iceweasel-UXP--- detects and blocks nonfree nontrivial JavaScript while allowing its execution on pages containing code that is either trivial and/or free. Many websites run nontrivial JavaScript on your computer. Some use it for complex tasks; many use it gratuitously for minor jobs that could be done easily with plain HTML. Sometimes this JavaScript code is malicious. Either way, the JavaScript code is often nonfree. For explanation of the issue, see "The JavaScript Trap"(@url{https://www.gnu.org/philosophy/javascript-trap.html}). If you care about freedom in your computing, and don't wish to let all and sundry make you run nonfree programs, now you can prevent it by using LibreJSXUL. @node Disclaimer @chapter Disclaimer @cindex disclaimer @itemize @bullet @item LibreJSXUL is not a security tool. Its goal is to detect nonfree nontrivial JavaScript, and it currently does not detect whether free or trivial code is malicious or not. Other free Mozilla extensions and add-ons may be available for this purpose. @item LibreJSXUL is always a work in progress. If you find a bug, please report it to @email{bug-librejs@@gnu.org}. @end itemize @node Installation @chapter Installation @cindex Installation You can install LibreJSXUL directly using a generated @file{librejsxul.xpi} file, or by building it from source. @section Building the Package After installing @code{jpm}, you should be able to use the @code{make} command to build LibreJSXUL from source. After running @code{make}, a new file, @file{librejsxul.xpi} should be generated. This is the file that can be installed in a Mozilla browser. @section Installing LibreJSXUL To install the add-on for all users, run: @example sudo make install @end example or as root: @example make install @end example Next time you open a Mozilla-browser as a user of your system, you should be notified that a new add-on (in this case, LibreJSXUL) as been installed and whether to allow it to run or not. @node How to Use @chapter How to Use @section LibreJSXUL in action After installing the add-on, you will see the LibreJSXUL widget in the add-on bar at the top right of the browser window. After loading a page, left-click on the widget to view the deactivated JavaScript code from the page (both on page and external) and, if applicable, the scripts that were accepted. @section Complaint Feature It is very important to complain when a site has nonfree JavaScript code, especially if it won't work without that code. LibreJSXUL makes it easy to complain by heuristically finding where to send the complaint. When nonfree/nontrivial code is detected in a page, LibreJSXUL attempts to find a relevant contact link or email for the website you are visiting. In order to do so, it will attempt to visit a few links from the current page (for instance, a link labeled ``contact'' on the same domain as the current page, @dots{}) LibreJSXUL detects contact pages, email addresses that are likely to be owned by the maintainer of the site, Twitter and identi.ca links, and phone numbers. After LibreJSXUL detects any of the above, a ``Complain'' tab will appear on the right of your web browser. When you click on this tab, a large panel will appear with contact information. Ideally, at the top you will find the email address of the maintainer, labeled as the ``Email you should use''. When you complain to the website for their nonfree nontrivial JavaScript, provide them with the link to the JavaScript Trap essay so that they can get more information on what the issue is and how they can solve it on their own site. LibreJSXUL includes a default subject line and body for the complaint email, with a link to the JavaScript Trap essay. This can be configured in the LibreJSXUL add-on preferences in your web browser. @section Options @table @dfn @item Whitelist LibreJSXUL lets you whitelist domain names and subdomains to bypass the regular JavaScript check. This might be useful, for example, if you are running your own code in a local web server. In order to add a whitelisted domain or url, go to Tools >> Add-ons, or press @kbd{Control + Shift + A}. Inside the add-on window, click on @dfn{Extensions}, and in the list, where you see LibreJSXUL, click on the @dfn{Preferences} button. You will see an input field labeled @dfn{Whitelist}. In the field, enter comma-separated domain names. Do not enter the protocol. For instance to whitelist all the pages of @url{https://www.gnu.org} and @url{https://gnu.org}, enter @samp{gnu.org}. To allow all subdomains from gnu.org, enter: @samp{*.gnu.org}. This will match such sites as @url{https://savannah.gnu.org} and @url{https://audio-video.gnu.org}. @item Complaint tab This specifies whether the complaint tab appears when a site is running nonfree JavaScript. @item Display notifications of JavaScript analysis This option enables an info bar of realtime JavaScript analysis. @item Complaint email subject Configure the default subject used in complaint emails. @item Complaint email body Configure the default body used in complaint emails. @end table @node JavaScript Detection @chapter JavaScript Detection @cindex javascript @itemize LibreJSXUL considers JavaScript on a page nontrivial if any of the following are true: @item It makes an AJAX request or is loaded along with scripts that make an AJAX request, @item It loads external scripts dynamically or is loaded along with scripts that do, @item It defines functions or methods and either loads an external script (from HTML) or is loaded as one, @item It uses dynamic JavaScript constructs that are difficult to analyze without interpreting the program or is loaded along with scripts that use such constructs. These constructs are: @itemize @item Using the eval function @item Calling methods with the square bracket notation @item Using any other construct than a string literal with certain methods (@code{Obj.write}, @code{Obj.createElement}, @dots{}). @end itemize @end itemize In practice, the JavaScript code in your page may be found trivial by LibreJSXUL if, as a whole: @itemize @bullet @item It does not define functions and it does not load external scripts (with the HTML src attribute in a @code{ @end example While @code{$.doSomething();} may seem trivial, you will nevertheless have to add a stylized license comment on your main HTML page because the external script (in this case jQuery) has been found to define methods that make AJAX calls. @code{$.doSomething()} might make an AJAX call, and LibreJSXUL does not check for that. The rule of thumb is that when you use a library or code that handles AJAX, JSON, JSONP, the loading of scripts dynamically, you should have license mentions for all your JavaScript files and for your main page regardless. In practice this is a case that happens very often with code that uses libraries. In practice also, the JavaScript code in an external file (an external @file{.js} file loaded on your page) may be found trivial if it does not define functions/methods. And in the same manner it will be considered nontrivial if AJAX calls, dynamic script loading, or non-obvious dynamic JavaScript constructs are used in another script. If your JavaScript code makes AJAX requests, it's important to get an accurate @dfn{Content-Type} in the response from the server. For example, if you're using JSON, set it to @code{application/json}. This is because LibreJSXUL alters the content of @code{text/html} responses. @node Free Licenses Detection @chapter Free Licenses Detection @cindex freelicenses @section Detected Free Licenses In order for a file to be detected as free, the license notice should appear in a JavaScript file above all code, at the very top of the file. For inline JavaScript code inside @code{