mirror of
https://github.com/arkenfox/user.js.git
synced 2025-09-01 01:18:30 +02:00
Compare commits
176 Commits
Author | SHA1 | Date | |
---|---|---|---|
ed993d5502 | |||
22d2d702be | |||
8dacf6e91f | |||
fbe1d48fe2 | |||
5fd7f6de7e | |||
592b959c24 | |||
c6f53c8768 | |||
38d772e4c8 | |||
cfce521919 | |||
a5ab3e23d6 | |||
b3eee6c9fd | |||
8d6d17d46b | |||
9a37e1340c | |||
f1e0203ef4 | |||
726d5bde30 | |||
f9f0fffd27 | |||
93840ca181 | |||
99aa5af356 | |||
0358fdac8b | |||
815c3026b5 | |||
5ed3047b7a | |||
e16ede1cdf | |||
6905187b3e | |||
172118e61b | |||
8452edb94b | |||
0f6957bbd4 | |||
8c2bcc0352 | |||
bc832575d8 | |||
c4b7e07691 | |||
58fb1db838 | |||
2809854802 | |||
091a71aade | |||
117ab133b1 | |||
c4a06c4689 | |||
0d27689c64 | |||
771e57480a | |||
f8fd03482d | |||
10cc1224d0 | |||
52926cca7a | |||
be64819ce7 | |||
24c228df92 | |||
892b3d9d69 | |||
df21798b81 | |||
46d03279d3 | |||
fe0af3bb34 | |||
84997386c1 | |||
1a389c0214 | |||
d0060fed3c | |||
3d18af19e3 | |||
b5b04454e0 | |||
618f7bed3f | |||
488a825626 | |||
aaf6cb33d7 | |||
77ecef8be3 | |||
4be0a80720 | |||
f573200aa8 | |||
48f258ff53 | |||
b9100488cb | |||
9d78e050ee | |||
b07cf1f03d | |||
683ef63b37 | |||
05580f5e99 | |||
ecc62554e5 | |||
f6e6de8444 | |||
f69d92e6dd | |||
3edc48da56 | |||
868882ae33 | |||
ff9bf76e52 | |||
4bc5b89cfe | |||
bb1e5bfd54 | |||
27d72eda9e | |||
07117c65c1 | |||
919d4bfe96 | |||
e38e253c25 | |||
14aaec71fb | |||
c0780df24d | |||
0ea1605642 | |||
bd384622db | |||
3366e0aa16 | |||
dff5bb478a | |||
d455c500a6 | |||
b90e72370c | |||
dd162d9f48 | |||
d7c276b3fe | |||
394b691599 | |||
ba83c555cc | |||
b695468c7e | |||
deae6e14f9 | |||
97c5378e52 | |||
d2dd0c2ab4 | |||
8c7149c6a5 | |||
d2da48c215 | |||
7e71b6663c | |||
94c83519f2 | |||
e7d20867cb | |||
55ae994972 | |||
f0945743b7 | |||
ee35d7c70d | |||
fe1b03bd2a | |||
187692af66 | |||
b6e2a3f64f | |||
6f7e09ad43 | |||
4ddf60cf32 | |||
24777c9ac2 | |||
615ebeda2f | |||
4139630635 | |||
a542701ba5 | |||
e67a0c868d | |||
1afd52de6e | |||
64f34f1471 | |||
5f3e3b2691 | |||
1ce1f74494 | |||
03f558b09c | |||
cd9fc110b0 | |||
7619e312de | |||
5d2c5de11c | |||
e1022c2e72 | |||
e431b324c8 | |||
18ad40a5c6 | |||
315de066ec | |||
85273d0f19 | |||
ef293b57a7 | |||
79d316fd22 | |||
ed60588473 | |||
07c128a190 | |||
5b1d56933b | |||
34cfcedc1b | |||
f9146fdf24 | |||
a1cdbc8324 | |||
cd07641a9d | |||
9c02949e04 | |||
1ef62a1036 | |||
5672bc8cc8 | |||
df1732745d | |||
30daf8640c | |||
4074a37e1d | |||
97043b0ce1 | |||
42ea484017 | |||
3f6340b69c | |||
884e84a4cb | |||
560acfc94f | |||
fb263f5624 | |||
19b392b83d | |||
2db76c95c3 | |||
b6fbf77dde | |||
a4ba22e912 | |||
163e18ce6d | |||
a13027905e | |||
8f76d9439f | |||
f0980b5cb8 | |||
450c9a9e0f | |||
6acfdaccbd | |||
a0e0a2a6c9 | |||
f67e729197 | |||
19526b573c | |||
b0221ec838 | |||
a3611b7cf8 | |||
bff1e84afa | |||
1d31da40ec | |||
0d57cfc44a | |||
0cfb2fb06d | |||
d5f297ed42 | |||
c13dbdf40d | |||
6173104a9e | |||
0c79b8b45b | |||
895f8d01d5 | |||
65dfad5c76 | |||
fdaf22780f | |||
16756646bb | |||
e4f80225d8 | |||
67eec9c85c | |||
539750d2f2 | |||
d91226ed55 | |||
301fcd059d | |||
1cc9a08a18 | |||
5d1857ddd8 |
@ -8,11 +8,11 @@ assignees: ''
|
||||
---
|
||||
|
||||
Before you proceed...
|
||||
- Keep reading this. Seriously.
|
||||
- Note that we do not support forks (i.e. IceCat, Pale Moon, WaterFox, etc).
|
||||
- Make sure you searched for the `[Setup` tags in the `user.js`.
|
||||
- Issues will be closed as invalid if you do not [troubleshoot](https://github.com/ghacksuserjs/ghacks-user.js/wiki/1.4-Troubleshooting), including
|
||||
- confirming the problem is caused by the `user.js`
|
||||
- searching the `[Setup` tags in the `user.js`
|
||||
- Search the GitHub repository. The information you need is most likely here already.
|
||||
- Check out our [troubleshooting](https://github.com/ghacksuserjs/ghacks-user.js/wiki/1.4-Troubleshooting) wiki page, including steps to see if the problem is caused by the `user.js` or an extension.
|
||||
- Note: We do not support forks
|
||||
|
||||
See also:
|
||||
- Extension breakage due to prefs [issue 391](https://github.com/ghacksuserjs/ghacks-user.js/issues/391)
|
||||
|
16
README.md
16
README.md
@ -1,26 +1,22 @@
|
||||
### ![][b] user.js
|
||||
A `user.js` is a configuration file that can control hundreds of Firefox settings. For a more technical breakdown and explanation, you can read more on the [overview](https://github.com/ghacksuserjs/ghacks-user.js/wiki/1.1-Overview) wiki page.
|
||||
|
||||
### ![][b] ghacks user.js
|
||||
The `ghacks user.js` is a **template** which aims to provide as much privacy and enhanced security as possible, and to reduce tracking and fingerprinting as much as possible - while minimizing any loss of functionality and breakage (but it will happen).
|
||||
### ![][b] This user.js
|
||||
This `user.js` is a **template** which aims to provide as much privacy and enhanced security as possible, and to reduce tracking and fingerprinting as much as possible - while minimizing any loss of functionality and breakage (but it will happen).
|
||||
|
||||
Everyone, experts included, should at least read the [implementation](https://github.com/ghacksuserjs/ghacks-user.js/wiki/1.3-Implementation) wiki page, as it contains important information regarding a few `ghacks user.js` settings.
|
||||
Everyone, experts included, should at least read the [implementation](https://github.com/ghacksuserjs/ghacks-user.js/wiki/1.3-Implementation) wiki page, as it contains important information regarding a few `user.js` settings.
|
||||
|
||||
Note that we do *not* recommend connecting over Tor on Firefox. Use the [Tor Browser](https://www.torproject.org/projects/torbrowser.html.en) if your [threat model](https://www.torproject.org/about/torusers.html.en) calls for it, or for accessing hidden services.
|
||||
|
||||
Also be aware that this `user.js` is made specifically for Firefox. Using it as-is in other Gecko-based browsers can be counterproductive, especially in the Tor Browser.
|
||||
Also be aware that this `user.js` is made specifically for desktop Firefox. Using it as-is in other Gecko-based browsers can be counterproductive, especially in the Tor Browser.
|
||||
|
||||
Sitemap: [Releases](https://github.com/ghacksuserjs/ghacks-user.js/releases), [changelogs](https://github.com/ghacksuserjs/ghacks-user.js/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3Achangelog), [Wiki](https://github.com/ghacksuserjs/ghacks-user.js/wiki), [stickies](https://github.com/ghacksuserjs/ghacks-user.js/issues?q=is%3Aissue+is%3Aopen+label%3A%22sticky+topic%22). [diffs](https://github.com/ghacksuserjs/ghacks-user.js/issues?q=is%3Aissue+label%3Adiffs)
|
||||
|
||||
### ![][b] acknowledgments
|
||||
Literally thousands of sources, references and suggestions. That said...
|
||||
Literally thousands of sources, references and suggestions. Special mention to:
|
||||
|
||||
* Martin Brinkmann at [ghacks](https://www.ghacks.net/) <sup>1</sup>
|
||||
* The ghacks community and commentators
|
||||
* [12bytes](https://12bytes.org/articles/tech/firefox/firefoxgecko-configuration-guide-for-privacy-and-performance-buffs)
|
||||
* The 12bytes article now uses this user.js and supplements it with an additional JS hosted at [GitLab](https://gitlab.com/labwrat/Firefox-user.js/tree/master)
|
||||
|
||||
<sup>1</sup> The ghacks user.js was an independent project by [Thorin-Oakenpants](https://github.com/Thorin-Oakenpants) started in early 2015 and was [first published](https://www.ghacks.net/2015/08/18/a-comprehensive-list-of-firefox-privacy-and-security-settings/) at ghacks in August 2015. With Martin Brinkmann's blessing, it will keep the ghacks name.
|
||||
* The 12bytes article now uses this user.js and supplements it with an additional JS hosted at [Codeberg](https://codeberg.org/12bytes.org/Firefox-user.js-supplement)
|
||||
|
||||
### ![][b] [](https://opensource.org/licenses/MIT)
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
## prefs.js cleaner for Linux/Mac
|
||||
## author: @claustromaniac
|
||||
## version: 1.1
|
||||
## version: 1.2
|
||||
|
||||
## special thanks to @overdodactyl and @earthlng for a few snippets that I stol..*cough* borrowed from the updater.sh
|
||||
|
||||
@ -27,7 +27,7 @@ fQuit() {
|
||||
fFF_check() {
|
||||
# there are many ways to see if firefox is running or not, some more reliable than others
|
||||
# this isn't elegant and might not be future-proof but should at least be compatible with any environment
|
||||
while [ -e webappsstore.sqlite-shm ]; do
|
||||
while [ -e lock ]; do
|
||||
echo -e "\nThis Firefox profile seems to be in use. Close Firefox and try again.\n"
|
||||
read -p "Press any key to continue."
|
||||
done
|
||||
@ -58,7 +58,7 @@ echo -e "\n\n"
|
||||
echo " ╔══════════════════════════╗"
|
||||
echo " ║ prefs.js cleaner ║"
|
||||
echo " ║ by claustromaniac ║"
|
||||
echo " ║ v1.1 ║"
|
||||
echo " ║ v1.2 ║"
|
||||
echo " ╚══════════════════════════╝"
|
||||
echo -e "\nThis script should be run from your Firefox profile directory.\n"
|
||||
echo "It will remove any entries from prefs.js that also exist in user.js."
|
||||
|
@ -1,7 +1,9 @@
|
||||
/***
|
||||
This will reset the preferences that are under sections 4600 & 4700 in the ghacks user.js
|
||||
up to and including release 60-beta. These are the prefs that are no longer necessary,
|
||||
or they conflict with, privacy.resistFingerprinting if you have that enabled.
|
||||
Version: up to and including FF/ESR78
|
||||
|
||||
This will reset the preferences that are under sections 4600 & 4700 in the
|
||||
ghacks user.js. These are the prefs that are no longer necessary, or they
|
||||
conflict with, privacy.resistFingerprinting if you have that enabled.
|
||||
|
||||
For instructions see:
|
||||
https://github.com/ghacksuserjs/ghacks-user.js/wiki/3.1-Resetting-Inactive-Prefs-[Scripts]
|
||||
@ -22,6 +24,10 @@
|
||||
'dom.w3c_touch_events.enabled',
|
||||
'media.ondevicechange.enabled',
|
||||
'webgl.enable-debug-renderer-info',
|
||||
'dom.w3c_pointer_events.enabled',
|
||||
'ui.use_standins_for_native_colors',
|
||||
'ui.systemUsesDarkTheme',
|
||||
'ui.prefersReducedMotion',
|
||||
/* section 4700 */
|
||||
'general.useragent.override',
|
||||
'general.buildID.override',
|
@ -1,6 +1,8 @@
|
||||
/***
|
||||
Version: up to and including FF/ESR78
|
||||
|
||||
This will reset the preferences that have been deprecated by Mozilla
|
||||
and used in the ghacks user.js up to and including release 60-beta
|
||||
and used in the ghacks user.js
|
||||
|
||||
It is in reverse order, so feel free to remove sections that do not apply
|
||||
|
||||
@ -12,8 +14,68 @@
|
||||
let ops = [
|
||||
/* deprecated */
|
||||
|
||||
/* ESR52.x users can remove sections 53-60 but it is not
|
||||
crucial as your user.js will reinstate them */
|
||||
/* 78 */
|
||||
'media.autoplay.enabled.user-gestures-needed',
|
||||
'toolkit.cosmeticAnimations.enabled',
|
||||
/* 77 */
|
||||
'browser.urlbar.oneOffSearches',
|
||||
'browser.tabs.remote.allowLinkedWebInFileUriProcess',
|
||||
/* 76 */
|
||||
'extensions.blocklist.url',
|
||||
/* 74 */
|
||||
'geo.wifi.uri',
|
||||
'geo.wifi.logging.enabled',
|
||||
'privacy.userContext.longPressBehavior',
|
||||
'webgl.disable-extensions',
|
||||
/* 72 */
|
||||
'browser.newtabpage.activity-stream.telemetry.ping.endpoint',
|
||||
'toolkit.telemetry.hybridContent.enabled',
|
||||
'dom.indexedDB.enabled',
|
||||
/* 71 */
|
||||
'devtools.webide.enabled',
|
||||
'devtools.webide.autoinstallADBExtension',
|
||||
'offline-apps.allow_by_default',
|
||||
/* 69 */
|
||||
'gfx.downloadable_fonts.woff2.enabled',
|
||||
'plugins.click_to_play',
|
||||
'media.autoplay.allow-muted',
|
||||
/* 68 */
|
||||
'browser.newtabpage.activity-stream.disableSnippets',
|
||||
'browser.aboutHomeSnippets.updateUrl',
|
||||
'lightweightThemes.update.enabled',
|
||||
'security.csp.experimentalEnabled',
|
||||
/* F67 */
|
||||
'dom.event.highrestimestamp.enabled',
|
||||
'browser.newtabpage.activity-stream.asrouter.userprefs.cfr',
|
||||
/* 66 */
|
||||
'browser.chrome.errorReporter.enabled',
|
||||
'browser.chrome.errorReporter.submitUrl',
|
||||
'network.allow-experiments',
|
||||
/* 65 */
|
||||
'browser.urlbar.autocomplete.enabled',
|
||||
'browser.fixup.hide_user_pass',
|
||||
/* 64 */
|
||||
'browser.onboarding.enabled',
|
||||
'devtools.webide.autoinstallADBHelper',
|
||||
'devtools.webide.adbAddonURL',
|
||||
'security.csp.enable_violation_events',
|
||||
/* 63 */
|
||||
'browser.search.countryCode',
|
||||
'app.update.enabled',
|
||||
'shield.savant.enabled',
|
||||
'browser.chrome.favicons',
|
||||
'media.autoplay.enabled',
|
||||
'network.cookie.lifetime.days',
|
||||
'browser.ctrlTab.previews',
|
||||
/* 62 */
|
||||
'plugin.state.java',
|
||||
/* 61 */
|
||||
'experiments.enabled',
|
||||
'experiments.manifest.uri',
|
||||
'experiments.supported',
|
||||
'experiments.activeExperiment',
|
||||
'network.jar.block-remote-files',
|
||||
'network.jar.open-unsafe-types',
|
||||
/* 60 */
|
||||
'browser.newtabpage.directory.source',
|
||||
'browser.newtabpage.enhanced',
|
||||
@ -22,7 +84,6 @@
|
||||
'extensions.shield-recipe-client.api_url',
|
||||
'browser.newtabpage.activity-stream.enabled',
|
||||
'dom.workers.enabled',
|
||||
'view_source.tab',
|
||||
/* 59 */
|
||||
'intl.locale.matchOS',
|
||||
'general.useragent.locale',
|
||||
@ -76,8 +137,6 @@
|
||||
'plugin.scan.WindowsMediaPlayer',
|
||||
'media.getusermedia.screensharing.allow_on_old_platforms',
|
||||
'dom.beforeAfterKeyboardEvent.enabled',
|
||||
/* End of ESR52.x section */
|
||||
|
||||
/* 52 */
|
||||
'network.http.sendSecureXSiteReferrer',
|
||||
'media.gmp-eme-adobe.enabled',
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
This will reset the preferences that have been removed completely from the ghacks user.js.
|
||||
|
||||
Last updated: 15-October-2019
|
||||
Last updated: 28-July-2020
|
||||
|
||||
For instructions see:
|
||||
https://github.com/ghacksuserjs/ghacks-user.js/wiki/3.1-Resetting-Inactive-Prefs-[Scripts]
|
||||
@ -204,14 +204,25 @@
|
||||
/* 70-beta */
|
||||
'browser.cache.disk_cache_ssl',
|
||||
'browser.sessionhistory.max_entries',
|
||||
'dom.push.connection.enabled',
|
||||
'dom.push.serverURL',
|
||||
'extensions.getAddons.discovery.api_url',
|
||||
'extensions.htmlaboutaddons.discover.enabled',
|
||||
'extensions.webservice.discoverURL',
|
||||
'intl.locale.requested',
|
||||
'intl.regional_prefs.use_os_locales',
|
||||
'dom.push.connection.enabled',
|
||||
'dom.push.serverURL',
|
||||
'privacy.usercontext.about_newtab_segregation.enabled',
|
||||
'security.insecure_connection_icon.pbmode.enabled',
|
||||
'security.insecure_connection_text.pbmode.enabled',
|
||||
'webgl.dxgl.enabled',
|
||||
/* 71-beta */
|
||||
'media.block-autoplay-until-in-foreground',
|
||||
'middlemouse.paste',
|
||||
/* 75-beta */
|
||||
'browser.search.geoip.url',
|
||||
'browser.search.region',
|
||||
/* 79-beta */
|
||||
'browser.urlbar.usepreloadedtopurls.enabled',
|
||||
/* reset parrot: check your open about:config after running the script */
|
||||
'_user.js.parrot'
|
||||
]
|
@ -1,65 +1,11 @@
|
||||
|
||||
/*** ghacks-user.js troubleshooter.js v1.5.2 ***/
|
||||
/*** ghacks-user.js troubleshooter.js v1.6.1 ***/
|
||||
|
||||
(function() {
|
||||
|
||||
if("undefined" === typeof(Services)) {
|
||||
alert("about:config needs to be the active tab!");
|
||||
return;
|
||||
}
|
||||
if ("undefined" === typeof(Services)) return alert('about:config needs to be the active tab!');
|
||||
|
||||
function getMyList(arr) {
|
||||
let aRet = [];
|
||||
let dummy = 0;
|
||||
for (let i = 0, len = arr.length; i < len; i++) {
|
||||
if (Services.prefs.prefHasUserValue(arr[i])) {
|
||||
dummy = Services.prefs.getPrefType(arr[i]);
|
||||
switch (dummy) {
|
||||
case 32: // string (see https://dxr.mozilla.org/mozilla-central/source/modules/libpref/nsIPrefBranch.idl#31)
|
||||
dummy = Services.prefs.getCharPref(arr[i]);
|
||||
aRet.push({'name':arr[i],'value': dummy,'type':32});
|
||||
break;
|
||||
case 64: // int
|
||||
dummy = Services.prefs.getIntPref(arr[i]);
|
||||
aRet.push({'name':arr[i],'value': dummy,'type':64});
|
||||
break;
|
||||
case 128: // boolean
|
||||
dummy = Services.prefs.getBoolPref(arr[i]);
|
||||
aRet.push({'name':arr[i],'value': dummy,'type':128});
|
||||
break;
|
||||
default:
|
||||
console.log("error detecting pref-type for '"+arr[i]+"' !");
|
||||
}
|
||||
}
|
||||
}
|
||||
return aRet;
|
||||
}
|
||||
|
||||
function reapply(arr) {
|
||||
for (let i = 0, len = arr.length; i < len; i++) {
|
||||
switch (arr[i].type) {
|
||||
case 32: // string
|
||||
Services.prefs.setCharPref(arr[i].name, arr[i].value);
|
||||
break;
|
||||
case 64: // int
|
||||
Services.prefs.setIntPref(arr[i].name, arr[i].value);
|
||||
break;
|
||||
case 128: // boolean
|
||||
Services.prefs.setBoolPref(arr[i].name, arr[i].value);
|
||||
break;
|
||||
default:
|
||||
console.log("error re-appyling value for '"+arr[i].name+"' !"); // should never happen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function myreset(arr) {
|
||||
for (let i = 0, len = arr.length; i < len; i++) {
|
||||
Services.prefs.clearUserPref(arr[i].name);
|
||||
}
|
||||
}
|
||||
|
||||
let ops = [
|
||||
const aPREFS = [
|
||||
|
||||
/* known culprits */
|
||||
'network.cookie.cookieBehavior',
|
||||
@ -160,56 +106,108 @@
|
||||
'last.one.without.comma'
|
||||
]
|
||||
|
||||
// any runtime-set pref that everyone will have and that can be safely reset
|
||||
const oFILLER = { type: 64, name: 'app.update.lastUpdateTime.browser-cleanup-thumbnails', value: 1580000000 };
|
||||
|
||||
// reset prefs that set the same value as FFs default value
|
||||
let aTEMP = getMyList(ops);
|
||||
myreset(aTEMP);
|
||||
reapply(aTEMP);
|
||||
function getMyList(arr) {
|
||||
const aRet = [];
|
||||
for (const sPname of arr) {
|
||||
if (Services.prefs.prefHasUserValue(sPname)) {
|
||||
const ptype = Services.prefs.getPrefType(sPname);
|
||||
switch (ptype) {
|
||||
case 32: // string (see https://dxr.mozilla.org/mozilla-central/source/modules/libpref/nsIPrefBranch.idl#31)
|
||||
aRet.push({'type':ptype,'name':sPname,'value':Services.prefs.getCharPref(sPname)});
|
||||
break;
|
||||
case 64: // int
|
||||
aRet.push({'type':ptype,'name':sPname,'value':Services.prefs.getIntPref(sPname)});
|
||||
break;
|
||||
case 128: // boolean
|
||||
aRet.push({'type':ptype,'name':sPname,'value':Services.prefs.getBoolPref(sPname)});
|
||||
break;
|
||||
default:
|
||||
console.log("error detecting pref-type for '"+sPname+"' !");
|
||||
}
|
||||
}
|
||||
}
|
||||
return aRet;
|
||||
}
|
||||
|
||||
const aBACKUP = getMyList(ops);
|
||||
//console.log(aBACKUP.length, "user-set prefs from our list detected and their values stored.");
|
||||
function reapply(arr) {
|
||||
for (const oPref of arr) {
|
||||
switch (oPref.type) {
|
||||
case 32: // string
|
||||
Services.prefs.setCharPref(oPref.name, oPref.value);
|
||||
break;
|
||||
case 64: // int
|
||||
Services.prefs.setIntPref(oPref.name, oPref.value);
|
||||
break;
|
||||
case 128: // boolean
|
||||
Services.prefs.setBoolPref(oPref.name, oPref.value);
|
||||
break;
|
||||
default:
|
||||
console.log("error re-appyling value for '"+oPref.name+"' !"); // should never happen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let myArr = aBACKUP;
|
||||
let found = false;
|
||||
let aDbg = [];
|
||||
focus();
|
||||
myreset(aBACKUP); // reset all detected prefs
|
||||
if (confirm("all detected prefs reset.\n\n!! KEEP THIS PROMPT OPEN AND TEST THE SITE IN ANOTHER TAB !!\n\nIF the problem still exists, this script can't help you - click cancel to re-apply your values and exit.\n\nClick OK if your problem is fixed.")) {
|
||||
aDbg = myArr;
|
||||
reapply(aBACKUP);
|
||||
myreset(myArr.slice(0, parseInt(myArr.length/2)));
|
||||
while (myArr.length >= 2) {
|
||||
function myreset(arr) {
|
||||
for (const oPref of arr) Services.prefs.clearUserPref(oPref.name);
|
||||
}
|
||||
|
||||
function resetAllMatchingDefault(arr) {
|
||||
const aTmp = getMyList(arr);
|
||||
myreset(aTmp);
|
||||
reapply(aTmp);
|
||||
}
|
||||
|
||||
function _main(aALL) {
|
||||
const _h = (arr) => Math.ceil(arr.length/2);
|
||||
|
||||
let aTmp = aALL, aDbg = aALL;
|
||||
reapply(aALL);
|
||||
myreset(aTmp.slice(0, _h(aTmp)));
|
||||
while (aTmp.length) {
|
||||
alert("NOW TEST AGAIN !");
|
||||
if (confirm("if the problem still exists click OK, otherwise click cancel.")) {
|
||||
myArr = myArr.slice(parseInt(myArr.length/2));
|
||||
if (myArr.length == 1) {
|
||||
alert("The problem is caused by more than 1 pref !\n\nNarrowed it down to "+ aDbg.length.toString() +" prefs, check the console ...");
|
||||
break;
|
||||
}
|
||||
aTmp = aTmp.slice(_h(aTmp));
|
||||
} else {
|
||||
myArr = myArr.slice(0, parseInt(myArr.length/2));
|
||||
aDbg = myArr;
|
||||
if (myArr.length == 1) { found = true; break; }
|
||||
aTmp = aTmp.slice(0, _h(aTmp));
|
||||
aDbg = aTmp; // update narrowed down list
|
||||
if (aDbg.length == 1) break;
|
||||
}
|
||||
reapply(aBACKUP);
|
||||
myreset(myArr.slice(0, parseInt(myArr.length/2))); // reset half of the remaining prefs
|
||||
reapply(aALL);
|
||||
myreset(aTmp.slice(0, _h(aTmp))); // reset half of the remaining prefs
|
||||
}
|
||||
reapply(aBACKUP);
|
||||
reapply(aALL);
|
||||
|
||||
if (aDbg.length == 1) return alert("narrowed it down to:\n\n"+aDbg[0].name+"\n");
|
||||
if (aDbg.length == aALL.length) {
|
||||
let msg = "Failed to narrow it down beyond the initial "+aALL.length+" prefs. The problem is most likely caused by at least 2 prefs!\n\n";
|
||||
msg += "Either those prefs are too far apart in the list or there are exactly 2 culprits and they just happen to be at the wrong place.\n\n";
|
||||
msg += "In case it's the latter, the script can add a dummy pref and you can try again - Try again?";
|
||||
if (confirm(msg)) return _main([...aALL, oFILLER]);
|
||||
} else if (aDbg.length > 10 && confirm("Narrowed it down to "+aDbg.length+" prefs. Try narrowing it down further?")) {
|
||||
return _main(aDbg.reverse());
|
||||
}
|
||||
|
||||
alert("Narrowed it down to "+ aDbg.length.toString() +" prefs, check the console ...");
|
||||
console.log("The problem is caused by 2 or more of these prefs:");
|
||||
for (const oPref of aDbg) console.log(oPref.name);
|
||||
}
|
||||
else {
|
||||
reapply(aBACKUP);
|
||||
|
||||
|
||||
resetAllMatchingDefault(aPREFS); // reset user-set prefs matching FFs default value
|
||||
|
||||
const aBAK = getMyList(aPREFS);
|
||||
//console.log(aBAK.length, "user-set prefs from our list detected and their values stored.");
|
||||
|
||||
focus();
|
||||
myreset(aBAK);
|
||||
if (!confirm("all detected prefs reset.\n\n!! KEEP THIS PROMPT OPEN AND TEST THE SITE IN ANOTHER TAB !!\n\nIF the problem still exists, this script can't help you - click cancel to re-apply your values and exit.\n\nClick OK if your problem is fixed.")) {
|
||||
reapply(aBAK);
|
||||
return;
|
||||
}
|
||||
|
||||
if (found) {
|
||||
alert("narrowed it down to:\n\n"+myArr[0].name+"\n");
|
||||
myreset(myArr); // reset the culprit
|
||||
}
|
||||
else {
|
||||
console.log("the problem is caused by a combination of the following prefs:");
|
||||
for (let i = 0, len = aDbg.length; i < len; i++) {
|
||||
console.log(aDbg[i].name);
|
||||
}
|
||||
}
|
||||
_main(aBAK);
|
||||
|
||||
})();
|
||||
|
156
updater.sh
156
updater.sh
@ -2,7 +2,7 @@
|
||||
|
||||
## ghacks-user.js updater for macOS and Linux
|
||||
|
||||
## version: 2.5
|
||||
## version: 2.7
|
||||
## Author: Pat Johnson (@overdodactyl)
|
||||
## Additional contributors: @earthlng, @ema-pe, @claustromaniac
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
readonly CURRDIR=$(pwd)
|
||||
|
||||
sfp=$(readlink -f "${BASH_SOURCE[0]}" 2>/dev/null || greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null)
|
||||
if [ -z "$sfp" ]; then sfp=${BASH_SOURCE[0]}; fi
|
||||
[ -z "$sfp" ] && sfp=${BASH_SOURCE[0]}
|
||||
readonly SCRIPT_DIR=$(dirname "${sfp}")
|
||||
|
||||
|
||||
@ -42,9 +42,9 @@ ESR=false
|
||||
# Download method priority: curl -> wget
|
||||
DOWNLOAD_METHOD=''
|
||||
if [[ $(command -v 'curl') ]]; then
|
||||
DOWNLOAD_METHOD='curl'
|
||||
DOWNLOAD_METHOD='curl --max-redirs 3 -so'
|
||||
elif [[ $(command -v 'wget') ]]; then
|
||||
DOWNLOAD_METHOD='wget'
|
||||
DOWNLOAD_METHOD='wget --max-redirect 3 --quiet -O'
|
||||
else
|
||||
echo -e "${RED}This script requires curl or wget.\nProcess aborted${NC}"
|
||||
exit 0
|
||||
@ -52,15 +52,15 @@ fi
|
||||
|
||||
|
||||
show_banner () {
|
||||
echo -e "${BBLUE}\n"
|
||||
echo ' ############################################################################'
|
||||
echo ' #### ####'
|
||||
echo ' #### ghacks user.js ####'
|
||||
echo ' #### Hardening the Privacy and Security Settings of Firefox ####'
|
||||
echo ' #### Maintained by @Thorin-Oakenpants and @earthlng ####'
|
||||
echo ' #### Updater for macOS and Linux by @overdodactyl ####'
|
||||
echo ' #### ####'
|
||||
echo ' ############################################################################'
|
||||
echo -e "${BBLUE}
|
||||
############################################################################
|
||||
#### ####
|
||||
#### ghacks user.js ####
|
||||
#### Hardening the Privacy and Security Settings of Firefox ####
|
||||
#### Maintained by @Thorin-Oakenpants and @earthlng ####
|
||||
#### Updater for macOS and Linux by @overdodactyl ####
|
||||
#### ####
|
||||
############################################################################"
|
||||
echo -e "${NC}\n"
|
||||
echo -e "Documentation for this script is available here: ${CYAN}https://github.com/ghacksuserjs/ghacks-user.js/wiki/3.3-Updater-Scripts${NC}\n"
|
||||
}
|
||||
@ -70,66 +70,50 @@ show_banner () {
|
||||
#########################
|
||||
|
||||
usage() {
|
||||
echo -e "${BLUE}\nUsage: $0 [-h] [-p PROFILE] [-u] [-d] [-s] [-n] [-b] [-c] [-v] [-r] [-e] [-o OVERRIDE]\n${NC}" 1>&2 # Echo usage string to standard error
|
||||
echo 'Optional Arguments:'
|
||||
echo -e "\t-h,\t\t Show this help message and exit."
|
||||
echo -e "\t-p PROFILE,\t Path to your Firefox profile (if different than the dir of this script)"
|
||||
echo -e "\t\t\t IMPORTANT: if the path include spaces, wrap the entire argument in quotes."
|
||||
echo -e "\t-l, \t\t Choose your Firefox profile from a list"
|
||||
echo -e "\t-u,\t\t Update updater.sh and execute silently. Do not seek confirmation."
|
||||
echo -e "\t-d,\t\t Do not look for updates to updater.sh."
|
||||
echo -e "\t-s,\t\t Silently update user.js. Do not seek confirmation."
|
||||
echo -e "\t-b,\t\t Only keep one backup of each file."
|
||||
echo -e "\t-c,\t\t Create a diff file comparing old and new user.js within userjs_diffs. "
|
||||
echo -e "\t-o OVERRIDE,\t Filename or path to overrides file (if different than user-overrides.js)."
|
||||
echo -e "\t\t\t If used with -p, paths should be relative to PROFILE or absolute paths"
|
||||
echo -e "\t\t\t If given a directory, all files inside will be appended recursively."
|
||||
echo -e "\t\t\t You can pass multiple files or directories by passing a comma separated list."
|
||||
echo -e "\t\t\t\t Note: If a directory is given, only files inside ending in the extension .js are appended"
|
||||
echo -e "\t\t\t\t IMPORTANT: do not add spaces between files/paths. Ex: -o file1.js,file2.js,dir1"
|
||||
echo -e "\t\t\t\t IMPORTANT: if any files/paths include spaces, wrap the entire argument in quotes."
|
||||
echo -e "\t\t\t\t\t Ex: -o \"override folder\" "
|
||||
echo -e "\t-n,\t\t Do not append any overrides, even if user-overrides.js exists."
|
||||
echo -e "\t-v,\t\t Open the resulting user.js file."
|
||||
echo -e "\t-r,\t\t Only download user.js to a temporary file and open it."
|
||||
echo -e "\t-e,\t\t Activate ESR related preferences."
|
||||
echo -e
|
||||
echo 'Deprecated Arguments (they still work for now):'
|
||||
echo -e "\t-donotupdate,\t Use instead -d"
|
||||
echo -e "\t-update,\t Use instead -u"
|
||||
echo -e
|
||||
echo
|
||||
echo -e "${BLUE}Usage: $0 [-bcdehlnrsuv] [-p PROFILE] [-o OVERRIDE]${NC}" 1>&2 # Echo usage string to standard error
|
||||
echo -e "
|
||||
Optional Arguments:
|
||||
-h Show this help message and exit.
|
||||
-p PROFILE Path to your Firefox profile (if different than the dir of this script)
|
||||
IMPORTANT: if the path includes spaces, wrap the entire argument in quotes.
|
||||
-l Choose your Firefox profile from a list
|
||||
-u Update updater.sh and execute silently. Do not seek confirmation.
|
||||
-d Do not look for updates to updater.sh.
|
||||
-s Silently update user.js. Do not seek confirmation.
|
||||
-b Only keep one backup of each file.
|
||||
-c Create a diff file comparing old and new user.js within userjs_diffs.
|
||||
-o OVERRIDE Filename or path to overrides file (if different than user-overrides.js).
|
||||
If used with -p, paths should be relative to PROFILE or absolute paths
|
||||
If given a directory, all files inside will be appended recursively.
|
||||
You can pass multiple files or directories by passing a comma separated list.
|
||||
Note: If a directory is given, only files inside ending in the extension .js are appended
|
||||
IMPORTANT: do not add spaces between files/paths. Ex: -o file1.js,file2.js,dir1
|
||||
IMPORTANT: if any files/paths include spaces, wrap the entire argument in quotes.
|
||||
Ex: -o \"override folder\"
|
||||
-n Do not append any overrides, even if user-overrides.js exists.
|
||||
-v Open the resulting user.js file.
|
||||
-r Only download user.js to a temporary file and open it.
|
||||
-e Activate ESR related preferences."
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
legacy_argument () {
|
||||
echo -e "${ORANGE}\nWarning: command line arguments have changed."
|
||||
echo -e "$1 has been deprecated and may not work in the future.\n"
|
||||
echo -e "Please view the new options using the -h argument.${NC}"
|
||||
}
|
||||
|
||||
#########################
|
||||
# File Handling #
|
||||
#########################
|
||||
|
||||
# Download files
|
||||
download_file () {
|
||||
declare -r url=$1
|
||||
download_file () { # expects URL as argument ($1)
|
||||
declare -r tf=$(mktemp)
|
||||
local dlcmd=''
|
||||
|
||||
if [ $DOWNLOAD_METHOD = 'curl' ]; then
|
||||
dlcmd="curl -o $tf"
|
||||
else
|
||||
dlcmd="wget -O $tf"
|
||||
fi
|
||||
|
||||
$dlcmd "${url}" &>/dev/null && echo "$tf" || echo '' # return the temp-filename (or empty string on error)
|
||||
$DOWNLOAD_METHOD "${tf}" "$1" && echo "$tf" || echo '' # return the temp-filename or empty string on error
|
||||
}
|
||||
|
||||
open_file () { #expects one argument: file_path
|
||||
if [ "$(uname)" == 'Darwin' ]; then
|
||||
open "$1"
|
||||
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
|
||||
elif [ "$(uname -s | cut -c -5)" == "Linux" ]; then
|
||||
xdg-open "$1"
|
||||
else
|
||||
echo -e "${RED}Error: Sorry, opening files is not supported for your OS.${NC}"
|
||||
@ -204,23 +188,22 @@ get_updater_version () {
|
||||
# Update updater.sh
|
||||
# Default: Check for update, if available, ask user if they want to execute it
|
||||
# Args:
|
||||
# -donotupdate: New version will not be looked for and update will not occur
|
||||
# -update: Check for update, if available, execute without asking
|
||||
# -d: New version will not be looked for and update will not occur
|
||||
# -u: Check for update, if available, execute without asking
|
||||
update_updater () {
|
||||
if [ $UPDATE = 'no' ]; then
|
||||
return 0 # User signified not to check for updates
|
||||
fi
|
||||
|
||||
declare -r tmpfile=$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/updater.sh')
|
||||
declare -r tmpfile="$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/updater.sh')"
|
||||
[ -z "${tmpfile}" ] && echo -e "${RED}Error! Could not download updater.sh${NC}" && return 1 # check if download failed
|
||||
|
||||
if [[ $(get_updater_version "${SCRIPT_DIR}/updater.sh") < $(get_updater_version "${tmpfile}") ]]; then
|
||||
if [ $UPDATE = 'check' ]; then
|
||||
echo -e "There is a newer version of updater.sh available. ${RED}Update and execute Y/N?${NC}"
|
||||
read -p "" -n 1 -r
|
||||
echo -e "\n\n"
|
||||
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||
return 0 # Update available, but user chooses not to update
|
||||
fi
|
||||
[[ $REPLY =~ ^[Nn]$ ]] && return 0 # Update available, but user chooses not to update
|
||||
fi
|
||||
else
|
||||
return 0 # No update available
|
||||
@ -238,11 +221,7 @@ update_updater () {
|
||||
|
||||
# Returns version number of a user.js file
|
||||
get_userjs_version () {
|
||||
if [ -e $1 ]; then
|
||||
echo "$(sed -n '4p' "$1")"
|
||||
else
|
||||
echo "Not detected."
|
||||
fi
|
||||
[ -e $1 ] && echo "$(sed -n '4p' "$1")" || echo "Not detected."
|
||||
}
|
||||
|
||||
add_override () {
|
||||
@ -252,7 +231,7 @@ add_override () {
|
||||
cat "$input" >> user.js
|
||||
echo -e "Status: ${GREEN}Override file appended:${NC} ${input}"
|
||||
elif [ -d "$input" ]; then
|
||||
FSAVEIFS=$IFS
|
||||
SAVEIFS=$IFS
|
||||
IFS=$'\n\b' # Set IFS
|
||||
FILES="${input}"/*.js
|
||||
for f in $FILES
|
||||
@ -271,12 +250,13 @@ remove_comments () { # expects 2 arguments: from-file and to-file
|
||||
|
||||
# Applies latest version of user.js and any custom overrides
|
||||
update_userjs () {
|
||||
declare -r newfile=$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js')
|
||||
declare -r newfile="$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js')"
|
||||
[ -z "${newfile}" ] && echo -e "${RED}Error! Could not download user.js${NC}" && return 1 # check if download failed
|
||||
|
||||
echo 'Please observe the following information:'
|
||||
echo -e "\tFirefox profile: ${ORANGE}$(pwd)${NC}"
|
||||
echo -e "\tAvailable online: ${ORANGE}$(get_userjs_version $newfile)${NC}"
|
||||
echo -e "\tCurrently using: ${ORANGE}$(get_userjs_version user.js)\n${NC}\n"
|
||||
echo -e "Please observe the following information:
|
||||
Firefox profile: ${ORANGE}$(pwd)${NC}
|
||||
Available online: ${ORANGE}$(get_userjs_version $newfile)${NC}
|
||||
Currently using: ${ORANGE}$(get_userjs_version user.js)${NC}\n\n"
|
||||
|
||||
if [ $CONFIRM = 'yes' ]; then
|
||||
echo -e "This script will update to the latest user.js file and append any custom configurations from user-overrides.js. ${RED}Continue Y/N? ${NC}"
|
||||
@ -298,9 +278,7 @@ update_userjs () {
|
||||
# backup user.js
|
||||
mkdir -p userjs_backups
|
||||
local bakname="userjs_backups/user.js.backup.$(date +"%Y-%m-%d_%H%M")"
|
||||
if [ $BACKUP = 'single' ]; then
|
||||
bakname='userjs_backups/user.js.backup'
|
||||
fi
|
||||
[ $BACKUP = 'single' ] && bakname='userjs_backups/user.js.backup'
|
||||
cp user.js "$bakname" &>/dev/null
|
||||
|
||||
mv "${newfile}" user.js
|
||||
@ -313,8 +291,10 @@ update_userjs () {
|
||||
|
||||
# apply overrides
|
||||
if [ "$SKIPOVERRIDE" = false ]; then
|
||||
while IFS=',' read -ra FILE; do
|
||||
add_override "$FILE"
|
||||
while IFS=',' read -ra FILES; do
|
||||
for FILE in "${FILES[@]}"; do
|
||||
add_override "$FILE"
|
||||
done
|
||||
done <<< "$OVERRIDE"
|
||||
fi
|
||||
|
||||
@ -334,14 +314,12 @@ update_userjs () {
|
||||
echo -e "Status: ${GREEN}A diff file was created:${NC} ${PWD}/${diffname}"
|
||||
else
|
||||
echo -e "Warning: ${ORANGE}Your new user.js file appears to be identical. No diff file was created.${NC}"
|
||||
if [ $BACKUP = 'multiple' ]; then
|
||||
rm $bakname &>/dev/null
|
||||
fi
|
||||
[ $BACKUP = 'multiple' ] && rm $bakname &>/dev/null
|
||||
fi
|
||||
rm $past_nocomments $current_nocomments $pastuserjs &>/dev/null
|
||||
fi
|
||||
|
||||
if [ "$VIEW" = true ]; then open_file "${PWD}/user.js"; fi
|
||||
[ "$VIEW" = true ] && open_file "${PWD}/user.js"
|
||||
}
|
||||
|
||||
#########################
|
||||
@ -349,16 +327,9 @@ update_userjs () {
|
||||
#########################
|
||||
|
||||
if [ $# != 0 ]; then
|
||||
readonly legacy_lc=$(echo $1 | tr '[A-Z]' '[a-z]')
|
||||
# Display usage if first argument is -help or --help
|
||||
if [ $1 = '--help' ] || [ $1 = '-help' ]; then
|
||||
usage
|
||||
elif [ $legacy_lc = '-donotupdate' ]; then
|
||||
UPDATE='no'
|
||||
legacy_argument $1
|
||||
elif [ $legacy_lc = '-update' ]; then
|
||||
UPDATE='yes'
|
||||
legacy_argument $1
|
||||
else
|
||||
while getopts ":hp:ludsno:bcvre" opt; do
|
||||
case $opt in
|
||||
@ -399,7 +370,8 @@ if [ $# != 0 ]; then
|
||||
ESR=true
|
||||
;;
|
||||
r)
|
||||
tfile=$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js')
|
||||
tfile="$(download_file 'https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js')"
|
||||
[ -z "${tfile}" ] && echo -e "${RED}Error! Could not download user.js${NC}" && exit 1 # check if download failed
|
||||
mv $tfile "${tfile}.js"
|
||||
echo -e "${ORANGE}Warning: user.js was saved to temporary file ${tfile}.js${NC}"
|
||||
open_file "${tfile}.js"
|
||||
|
Reference in New Issue
Block a user