Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Disable Javascript in Firefox from command line?

1,093 views
Skip to first unread message

VanguardLH

unread,
Sep 26, 2015, 11:30:57โ€ฏAM9/26/15
to mozilla-sup...@lists.mozilla.org
Firefox 40.0.3
Windows 7 Home x64 SP-1

Does Firefox have a command-line switch to disable Javascripting?

What I've looked at so far:
- about:config - Load Firefox, go into about:config, disable Javascript,
visit site, exit site, go into about:config, enable Javascript.
That's level of user effort is ridiculous. Even when the GUI had the
disable Javascript option, that required I wander through the options
before visiting a site (and do so again after leaving a site).
- Prebar - Have to load Firefox before I can use the add-on and before
the site can be visited. The default will NOT have Javascripting
disabled; that is, I don't want to keep enabling Javascript 99% of the
time. Add-ons are too late for URLs specified in the command line.
- NoScript - Too corrosive, active all the time versus on-demand. Have
to temporarily allow on about every site that I visit which voids the
purpose of NoScript. NoScript is like using a canon to swat a fly.
- Using a batch file to use vim, regex, or whatever to edit prefs.js
means affecting other current or future instances of Firefox. I only
want to disable Javascript on-demand.

I want to on-demand decide if an instance of Firefox will have
Javascripting disabled. I do NOT want Javascripting disabled by default
on every load of Firefox. I do not want to load Firefox and then change
enable/disable or temporarily allow or have to whitelist Javascripting.
A command-line switch to disable Javascripting means I can also specify
the URL of a site to visit, and Javascripting would only be disabled for
that instance of Firefox. No fiddling with add-ons or manual config.

I've searched but cannot find a site listing command-line switches for
Firefox that mention how to disable Javascripting. With all the other
command-line arguments, why would Mozilla omit this one?

WaltS48

unread,
Sep 26, 2015, 11:37:16โ€ฏAM9/26/15
to mozilla-sup...@lists.mozilla.org
Have you looked at YesScript?

<https://addons.mozilla.org/en-US/firefox/addon/yesscript/>

--
Linux Mint 17.2 "Rafaela" | KDE 4.14.2 | Thunderbird 44.0a1 (Daily)
One users useless feature, is a useful feature to another
Go Bucs! Go Pens! Go Pitt! Go Saints!
[Visit Pittsburgh]<http://www.visitpittsburgh.com/>
[Coexist ยท Understanding Across Divides]<https://www.coexist.org/>

EE

unread,
Sep 26, 2015, 4:02:21โ€ฏPM9/26/15
to mozilla-sup...@lists.mozilla.org
What you want is YesScript. It makes a blacklist rather than a
whitelist, and all it does is block javascript.

Ralph Fox

unread,
Sep 27, 2015, 1:06:05โ€ฏAM9/27/15
to mozilla-sup...@lists.mozilla.org
On Fri, 25 Sep 2015 21:33:49 -0500, VanguardLH wrote:

> Firefox 40.0.3
> Windows 7 Home x64 SP-1
>
> Does Firefox have a command-line switch to disable Javascripting?


Yes with a little lateral thinking...

1) Firefox has a command-line switch to select which profile to use.

2) You can have two profiles, one profile with JavaScript enabled and
the other profile with JavaScript disabled. Use a command-line
switch to select which of the two profiles to use.


--
Kind regards
Ralph

J. P. Gilliver (John)

unread,
Sep 27, 2015, 5:56:25โ€ฏAM9/27/15
to mozilla-sup...@lists.mozilla.org
In message
<mailman.2276.144329773...@lists.mozilla.org>, EE
<nu...@bees.wax> writes:
>VanguardLH wrote:
>> Firefox 40.0.3
>> Windows 7 Home x64 SP-1
>>
>> Does Firefox have a command-line switch to disable Javascripting?
[]
>> - NoScript - Too corrosive, active all the time versus on-demand. Have
>> to temporarily allow on about every site that I visit which voids the
>> purpose of NoScript. NoScript is like using a canon to swat a fly.

Since flies are also god's creatures, some canons may not wish to swat
them anyway ... (-:
[]
>What you want is YesScript. It makes a blacklist rather than a
>whitelist, and all it does is block javascript.
>
+1
--
J. P. Gilliver. UMRA: 1960/<1985 MB++G()AL-IS-Ch++(p)Ar@T+H+Sh0!:`)DNAf

"Stupidity is solo; it takes at least 2 to have a bureaucracy" - Tom Galloway

VanguardLH

unread,
Sep 27, 2015, 9:17:33โ€ฏAM9/27/15
to mozilla-sup...@lists.mozilla.org
But how would I enter a site into its blacklist before the web browser
was even running? Add-ons are too late. I'd have to open the web
browser to a non-functional page (e.g., about:blank) to blacklist the
site that I was going to visit and then visit the site. Doable but a
chore. Instead I'd prefer to NOT use add-ons (as noted) and instead use
a command line with a switch to disable Javascript and optionally the
URL to the unknown and untrusted site.

If there some way to edit the blacklist in the add-on then I might as
well skip the add-on and use a batch file that edits the prefs.js file
(that's where the about:config settings are, right?) before loading the
web browser. Since the add-on preferences are shown in about:config,
I'd be editing the prefs.js file, anyway> I wouldn't need an add-on.
I'd already be editing prefs.js to set javascript.enabled to false. The
batch script would edit the prefs.js file to add the following line:

user_pref("javascript.enabled", false);

After exiting Firefox, the batch file would delete that line (since its
absence default to a true value). Alas, that also means during the time
the batch file is loaded that any existing instances of firefox.exe and
any that I open later would have Javascript disabled.

I take it Mozilla has decided not to add a command-line switch so I
could run "firefox.exe -nojs <url>". I haven't mention of one but it's
always possible the search criteria doesn't hit the relevant article. I
typically only read relevant articles up to the first 50 hits. A
command-line switch would be so much easier than having to write up a
batch file and editing script.

If I'm stuck having to edit prefs.js before loading firefox.exe, what's
a good editor to do command-line edits? I remember using sed back on
Linux to open it and pass (pipe) command into it. I really don't want
to install Cygwin just to get sed. I remember using the ancient edlin
to do similar to sed (but without regex) but that's not in Win7 (don't
know when Microsoft drop that console-mode editor). As I recall, there
is a VIM for Windows. Does it do command-line instructions? Eh, maybe
it's time I learn a little PowerShell.

VanguardLH

unread,
Sep 27, 2015, 9:20:18โ€ฏAM9/27/15
to mozilla-sup...@lists.mozilla.org
Ah, that would work. Beats using a script to edit the prefs.js file.

VanguardLH

unread,
Oct 10, 2015, 10:26:36โ€ฏAM10/10/15
to mozilla-sup...@lists.mozilla.org
After getting some time to look back at this issue, I had defined
bookmarks using the keyword value of a bookmark to call that bookmark
and using %s in the URL string for the book mark to pass a string to the
URL to pre-fill the input string and do the search at the search site.
This worked well but required me to enter the bookmark's keyword (as a
prefix) in the address bar and then copy-n-paste a string from the web
page into the address bar (after the keyword prefix). It worked but
required more steps than I would prefer (compared to IE's accelerators).

Finally I found an add-on that provided a right-click context menu
searches list to use on text highlighted in a web page: SmartSearch
(https://addons.mozilla.org/en-US/firefox/addon/smartsearch/). I
haven't gotten around to investigating how it all works but it
immediately populated its popup list from the context menu to include
the bookmarks that had a non-blank keyword value (the ones where I added
"%s=" to the end of the bookmarks' URLs). I had created a folder named
"Search providers" in my Bookmarks list where each had a URL to the
search site with %s and a keyword.

Installing SmartSearch immediately added a context menu entry to let me
pick which search provider to use on the selected text. I can now add
more search accelerators than I had in IE (which required you installed
from those that are available instead of every keyworded bookmark you
define with %s). I can still use the keyword followed by a string in
Firefox's address bar but now I can more easily use the content menu.

MrGatoChile

unread,
Oct 11, 2015, 1:44:16โ€ฏPM10/11/15
to mozilla-sup...@lists.mozilla.org
Firefox by default search using the current engine, if you add search
engines with the next addon they will available to use.

To add an engine you have to rightclick in the searchbox of the
searchengine and select "add to searchbar", you can add a searchprefix
if you desired.

If you wish you can search highligthing text with the current engine.

https://addons.mozilla.org/es/firefox/addon/add-to-search-bar/?src=external-Add-ons_Manager_Context_Menu-extension

VanguardLH

unread,
Oct 11, 2015, 5:28:29โ€ฏPM10/11/15
to mozilla-sup...@lists.mozilla.org
Must've been reading my other thread (about IE accelerators in Firefox)
but had this thread highlighted when I replied. My reply should've been
under the other thread.

Anyway, I have 3 search engines added to Firefox: Google, Bing,
DuckDuckGo, and Wikipedia. Where is the "searchbox of the
searchengine"? There is a search box in the toolbar row (with the
address bar). Right-clicking on that brings up no such option to "add
to searchbar". In the options to select/configure search engines,
right-click does nothing.

The add-on modifies Firefox's searchbox. That would mean that I would
have to manually enter the search string or copy and paste it from the
web page into the searchbox. I can already do that with keywords for
bookmarks by using the keyword followed by the manually written or
pasted string in the address bar of Firefox.

As for the add-on modifying the searchbox to allow selecting different
search engines, Firefox already has that. When I input or paste a
string into the searchbox, Firefox will pop up a selection dialog to let
me pick which installed search engine to use. So when I enter some
string in the searchbox, Firefox popup a dialog showing Bing,
DuckDuckGo, and Wikipedia as alternate search engines (Google is the
default so it doesn't have to be listed). If some string was already
entered but the popup choice dialog doesn't appear (it shows up while
entering a string), the green "+" icon lets me pop open the search
choice popup.

Perhaps the purpose of the add-on you mentioned is to add more search
choices than just the installable search engines. That is, add any web
site that has a search function (and which will take search criteria as
arguments in the URL). I don't much use the searchbox anymore. If I
want to do a search where I manually enter the search string or paste it
from text copied from the web page, I just use the addressbar by using
the keyword for the bookmarked search site. Adding the keyword is
little work to utilize a feature already built into Firefox's bookmarks.
Plus having to roll my eyes up and down a long list of search sites in a
list would be a nuisance. I've already memorized the keywords. In
fact, for the add-on that I mentioned, having a flat list of search
sites was also a nuisance, so I grouped them into subfolders in my
bookmarks, one for Google sites, another for Bing, another for
references, and so on. Makes the list more organized and shorter.

Thanks for the suggestion. It adds to the searchbox but I rarely use
that. After highlighting text in a web page, the add-on that I found
makes it quick, easy, and organized to pick a search site. No having to
copy the highlighted string and then paste into the searchbox (for your
add-on) or after a bookmark's keyword in the addressbar.

Ralph Fox

unread,
Oct 12, 2015, 4:44:42โ€ฏAM10/12/15
to mozilla-sup...@lists.mozilla.org
On Sun, 11 Oct 2015 15:44:16 -0500, VanguardLH wrote:

> Anyway, I have 3 search engines added to Firefox: Google, Bing,
> DuckDuckGo, and Wikipedia. Where is the "searchbox of the
> searchengine"? There is a search box in the toolbar row (with the
> address bar). Right-clicking on that brings up no such option to "add
> to searchbar". In the options to select/configure search engines,
> right-click does nothing.


Let me provide an example.

1. Pick one of these search engines which is _not_ yet added to
your Firefox, and go to the page Firefox.
https://www.yandex.com/
https://en.wiktionary.org/wiki/Special:Search
https://www.mojeek.co.uk/
http://www.ansearch.com.au/
https://www.ixquick.com/

I will use Yandex as an example.

2. While you are at the (say) Yandex search page, look at Firefox's
search box. You will see a green '+' on top of the magnifying
glass icon.

3. [Left] Click on the '+' or the magnifying glass icon. In the pull-down
menu, you will see an option (say) 'Add "Yandex"'

Animated screen-shot ---> http://imgur.com/fuH6wTo

4. If you click the (say) 'Add "Yandex"' in the pull-down menu, it
will add Yandex to Firefox's search engines.


--
Kind regards
Ralph

Ed Mullen

unread,
Oct 12, 2015, 11:39:18โ€ฏAM10/12/15
to mozilla-sup...@lists.mozilla.org
Interesting. No plus sign here. FF 42.0b5.


--
Ed Mullen
http://edmullen.net/
If you have a difficult task, give it to a lazy person; they'll find an
easier way to do it.

VanguardLH

unread,
Oct 12, 2015, 11:57:58โ€ฏAM10/12/15
to mozilla-sup...@lists.mozilla.org
But that is a feature within Firefox. I wouldn't neen Gato's suggested
add-on for that.

Adding search sites to the searchbox doesn't add them to the right-click
content menu when right-clicking on highlighted text in a web page. I
would still have top copy the highlighted web page string and paste into
the searchbox to then select from one of the added search sites.

Whether I used a context menu search or the searchbox, and to use a
string in the web page, I would have to highlight the string. So that
is a step needed for either method. For a context menu search, I
right-click and select search site (using the add-on that I mentioned).
To use the searchbox, I right-click and click on Copy (2 mouse clicks,
or 2 keypresses for Ctrl+C), click in the searchbox to set focus there,
right-click and click Paste (or 2 clicks, or 2 keypresses via Ctrl+V),
and click on a search site listed in the popup list dialog.

Context menu search:
2 or 3 mouse clicks

Searchbox search:
6 mouse clicks
or
2 keypresses, 1 mouse click, 2 keypresses, 1 mouse click

The context menu search scheme is easier and faster. If I was averse to
adding another add-on (I have only 6 with 1 being a simple toggle of
Javascript in prefs.js and 1 being search add-on that adds to the
context menu), I'd go your route since that uses a feature that is built
into Firefox.

VanguardLH

unread,
Oct 12, 2015, 2:11:20โ€ฏPM10/12/15
to mozilla-sup...@lists.mozilla.org
There are lots of online articles on how to disable the One-Click Search
List feature. Maybe you disable it.

After visiting yandex.com and using the magifying glass icon (green "+")
in the searchbox, Yandex gets added to the search list. Under the path:

C:\Users\<myacct>\AppData\Roaming\Mozilla\Firefox\Profiles\<ffprofile>.default\

gets created the file:

searchplugins\yandex.xml

which has:

https://yandex.com/yandsearch?text={searchTerms}&from=os&clid=1836587

for its search URL. Apparently "{searchTerms}" gets replaced with the
string you enter into the searchbox. I went to ixquick.com and used the
green "+" icon to add that search site to the list. An .xml file was
created in the searchplugins subfolder with a similar search URL using
"{searchTerms}" as a replaceable value.

There does seem a difference in installed search providers and added
search sites. The new files under the searchplugins subfolder only
appear when adding a search site (via green "+" icon), not when
installing a search provider.

What I have not found online is a description of how Firefox detects a
site's page as a search "landing" page and what URL to use for
submitting search criteria. The searchbox's magifying glass icon just
brings up the list of search providers. What gets Firefox to detect a
page is a search site to then add the green "+" icon (along with adding
the "Add <site>" choice in the list dialog) is what I don't know yet.

If I go to support.mozilla.org, Firefox adds the green "+" overlay to
the magnifying glass icon in the searchbox. Perhaps Firefox is just
looking for an input object on a page where users enter some text. At
the Mozilla support site, there is a searchbox in the web page:

<form data-instant-search="form"
id="support-search"
action="/en-US/search"
method="get"
class="simple-search-form">
<input
name="q"
required="required"
aria-required="true"
placeholder="Search Mozilla Support"
class="searchbox"
id="search-q"
type="search">
<button
type="submit"
title="Search"
class="submit-button">
Search
</button>

</form>

The page has an input field (and a button) object for the user to enter
a string upon which to search. When I go to cnn.com, there is no green
"+" overlay on the magnifier icon in Firefox's searchbox. The code for
the search field in that wab page is:

<form method="get"
action="/search/"
name="headerSearch">
<input class="search__input-field"
placeholder="Search CNN"
id="searchInputNav"
name="text" type="text">
<button class="search__button"
type="submit"
role="button">
<span class="search__button-text">
Search
</span>
</button>
</form>

For the Mozilla page, the input field has an ID (name) of "search-q".
At the CNN site, the input field has a name of "searchInputNav". Could
be Firefox is looking for input fields with recognizable names for those
objects, and CNN's name isn't in Firefox's list of recognized object
names.

Yet I went to forum.avast.com which has a search field (input object
with name of "search") and there was no green "+" overlay. "search" is
about as basic a name for an input object as you can get to identify it
is to input the search string.

So it seems Mozilla hardcoded some fixed list of search sites where upon
visit then Firefox will show the green "+" overlay on the searchbox's
magnifier icon. I have found no one via online searches describing just
how Firefox will determine when it will add the green "+" overlay and
add the "Add <site>" option to the search list dialog. So, as far as I
am concerned, it just some FM that someone added to Firefox that cannot
be relied upon because how it works is not defined.

https://bugzilla.mozilla.org/show_bug.cgi?id=1106432

Apparently the green "+" overlay (on the magnifier icon) was an
afterthought. There already was the feature that you could click on the
magnifier icon to see the "Add <site>" option when Firefix detected an
"open search" (whatever that means). Instead of making users keep
clicking on the magnifier icon to see if they could add a site to the
search list, the green "+" overlay icon was to show the availability to
add the site to the search list.

>From the above bug report and mention of "open search discovery", I did
an online search on "firefox open search discovery" and found:

https://developer.mozilla.org/en-US/Add-ons/Creating_OpenSearch_plugins_for_Firefox

For a web site to offer an open search template usable by clients:

http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_document

Notice the template has the q={searchTerms} argument that I noted
finding in the .xml file created under the searchplugins subfolder. So
the site has to provide the template for how the client will support an
"open search" template which then gets copied down to the client.

So I went back to yandex.com to see how they were delivering the
OpenSearch template. There I found:

<link rel="search" href="//yandex.com/opensearch.xml" title="Yandex"
type="application/opensearchdescription+xml">

So the site has to support the OpenSearch protocol, provide a template
for how to do the search (the template URL), that gets downloaded to the
client (Firefox), and the client then uses that template. Whew, what a
bunch of work to figure out how this, um, stuff works.

The Yandex site is providing the .xml file to support OpenSearch and
Firefox downloaded that file and stored it under the searchplugins
subfolder and added Yandex to my list of search providers. So the
framework is there. If you are not getting the green "+" overlay or the
"Add <site>" to the search list dialog then perhaps you have an add-on
that is interferring with this feature, or your unreleased version of
Firefox has a bug (which happens a lot with unreleased versions).
0 new messages