mirror of
https://github.com/arkenfox/user.js.git
synced 2025-11-22 16:35:16 +01:00
Compare commits
108 Commits
57.0
...
v59.0-alph
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
457611f079 | ||
|
|
09aca71822 | ||
|
|
f90193ab76 | ||
|
|
ffced9b4c0 | ||
|
|
0b3395b520 | ||
|
|
d4a20165ef | ||
|
|
089f0826cf | ||
|
|
b83d53e681 | ||
|
|
14456b5a29 | ||
|
|
517e40703f | ||
|
|
7f7282a975 | ||
|
|
6fd415eab2 | ||
|
|
d4083e6a3e | ||
|
|
3192027f52 | ||
|
|
2a402310cc | ||
|
|
1469e13df8 | ||
|
|
92585ecd93 | ||
|
|
205d64ab29 | ||
|
|
3812aed9e9 | ||
|
|
a83f5a0f5f | ||
|
|
19c40eeb18 | ||
|
|
61d2b46a02 | ||
|
|
b93c7e026c | ||
|
|
ec687cad75 | ||
|
|
6b691ae7e3 | ||
|
|
40da3653d3 | ||
|
|
77a5894fa0 | ||
|
|
11bcf46063 | ||
|
|
2dd2f5febe | ||
|
|
2de13258ff | ||
|
|
40391a26a2 | ||
|
|
50186412e4 | ||
|
|
9892c3cbb7 | ||
|
|
887e93a4f2 | ||
|
|
7f1a82365c | ||
|
|
8996071cd0 | ||
|
|
cc166b8091 | ||
|
|
0260176fef | ||
|
|
09e2b181e4 | ||
|
|
4dafbb89df | ||
|
|
5e08ad8c60 | ||
|
|
6366ab8afc | ||
|
|
2980073bca | ||
|
|
e8b9f72885 | ||
|
|
b502317caf | ||
|
|
5385b8c4ab | ||
|
|
17fe261170 | ||
|
|
3d5276484a | ||
|
|
542b814814 | ||
|
|
0473c73860 | ||
|
|
a6fd4d1db1 | ||
|
|
95251e98da | ||
|
|
08a5410b88 | ||
|
|
93a8f89191 | ||
|
|
4fdf322193 | ||
|
|
ca11a88189 | ||
|
|
a290b3ad3d | ||
|
|
d924c01518 | ||
|
|
1738f9efb1 | ||
|
|
3ef5ba3ac7 | ||
|
|
2969ab5b13 | ||
|
|
3405bae6d8 | ||
|
|
a4eaf9494e | ||
|
|
ea6e9be787 | ||
|
|
0ebe5d0fa8 | ||
|
|
ff77f7260c | ||
|
|
93c3457d18 | ||
|
|
bc371c8c9d | ||
|
|
622b70aa37 | ||
|
|
c83670f708 | ||
|
|
c399bb1d2d | ||
|
|
0a11a87fd0 | ||
|
|
91521dbc84 | ||
|
|
14c1620994 | ||
|
|
0da73d606b | ||
|
|
6a0f162d64 | ||
|
|
038201fb07 | ||
|
|
91c8da5f12 | ||
|
|
22198d420a | ||
|
|
6becf50fe6 | ||
|
|
4fb3040042 | ||
|
|
5005376742 | ||
|
|
48f95f2ac7 | ||
|
|
e5c14eb700 | ||
|
|
7a3810f6ca | ||
|
|
c8d7694fd3 | ||
|
|
343f77c5e9 | ||
|
|
a0ec17955d | ||
|
|
e195aceb54 | ||
|
|
6882a64bf2 | ||
|
|
806d6edc6d | ||
|
|
d1ab8fd10c | ||
|
|
db97478cd1 | ||
|
|
48ec3da18d | ||
|
|
8c35bf5d11 | ||
|
|
a3bffb83bd | ||
|
|
b30b988137 | ||
|
|
f820ecbacb | ||
|
|
3acef78f59 | ||
|
|
ac16b9c77b | ||
|
|
1069915372 | ||
|
|
978e51b515 | ||
|
|
c5374b60d8 | ||
|
|
2a2b80902a | ||
|
|
d82791a933 | ||
|
|
d89e9834ff | ||
|
|
04c7ed94da | ||
|
|
c82d6f70fe |
@@ -6,14 +6,14 @@ The `ghacks user.js` is a **template**, which, as provided, aims to provide as m
|
|||||||
|
|
||||||
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 `ghacks user.js` settings.
|
||||||
|
|
||||||
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)
|
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)
|
||||||
|
|
||||||
###  acknowledgments
|
###  acknowledgments
|
||||||
Literally thousands of sources, references and suggestions. That said...
|
Literally thousands of sources, references and suggestions. That said...
|
||||||
|
|
||||||
* Martin Brinkmann at [ghacks](https://www.ghacks.net/) <sup>1</sup>
|
* Martin Brinkmann at [ghacks](https://www.ghacks.net/) <sup>1</sup>
|
||||||
* The ghacks community and commentators
|
* The ghacks community and commentators
|
||||||
* [12bytes](http://12bytes.org/tech/firefoxgecko-configuration-guide-for-privacy-and-performance-buffs)
|
* [12bytes](http://12bytes.org/tech/firefox/firefoxgecko-configuration-guide-for-privacy-and-performance-buffs)
|
||||||
* The 12bytes article now uses this user.js and supplements it with an additonal JS hosted right [here](https://github.com/atomGit/Firefox-user.js) at github
|
* The 12bytes article now uses this user.js and supplements it with an additonal JS hosted right [here](https://github.com/atomGit/Firefox-user.js) at github
|
||||||
|
|
||||||
<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.
|
<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.
|
||||||
|
|||||||
216
scratchpad-scripts/troubleshooter.js
Normal file
216
scratchpad-scripts/troubleshooter.js
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
|
||||||
|
/*** ghacks-user.js troubleshooter.js v1.5 ***/
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
if("undefined" === typeof(Services)) {
|
||||||
|
alert("about:config needs to be the active tab!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = [
|
||||||
|
|
||||||
|
/* known culprits */
|
||||||
|
'network.cookie.cookieBehavior',
|
||||||
|
'network.http.referer.XOriginPolicy',
|
||||||
|
'privacy.firstparty.isolate',
|
||||||
|
'privacy.resistFingerprinting',
|
||||||
|
'security.mixed_content.block_display_content',
|
||||||
|
'svg.disabled',
|
||||||
|
|
||||||
|
/* Storage + Cache */
|
||||||
|
'browser.cache.offline.enable',
|
||||||
|
'dom.indexedDB.enabled',
|
||||||
|
'dom.storage.enabled',
|
||||||
|
'browser.storageManager.enabled',
|
||||||
|
'dom.storageManager.enabled',
|
||||||
|
|
||||||
|
/* Workers, Web + Push Notifications */
|
||||||
|
'dom.caches.enabled',
|
||||||
|
'dom.push.connection.enabled',
|
||||||
|
'dom.push.enabled',
|
||||||
|
'dom.push.serverURL',
|
||||||
|
'dom.serviceWorkers.enabled',
|
||||||
|
'dom.workers.enabled',
|
||||||
|
'dom.webnotifications.enabled',
|
||||||
|
'dom.webnotifications.serviceworker.enabled',
|
||||||
|
|
||||||
|
/* Fonts */
|
||||||
|
'browser.display.use_document_fonts',
|
||||||
|
'font.blacklist.underline_offset',
|
||||||
|
'gfx.downloadable_fonts.woff2.enabled',
|
||||||
|
'gfx.font_rendering.graphite.enabled',
|
||||||
|
'gfx.font_rendering.opentype_svg.enabled',
|
||||||
|
'layout.css.font-loading-api.enabled',
|
||||||
|
|
||||||
|
/* Misc */
|
||||||
|
'browser.link.open_newwindow.restriction',
|
||||||
|
'canvas.capturestream.enabled',
|
||||||
|
'dom.event.clipboardevents.enabled',
|
||||||
|
'dom.event.contextmenu.enabled',
|
||||||
|
'dom.IntersectionObserver.enabled',
|
||||||
|
'dom.popup_allowed_events',
|
||||||
|
'full-screen-api.enabled',
|
||||||
|
'geo.wifi.uri',
|
||||||
|
'intl.accept_languages',
|
||||||
|
'javascript.options.asmjs',
|
||||||
|
'javascript.options.wasm',
|
||||||
|
'permissions.default.shortcuts',
|
||||||
|
'security.csp.experimentalEnabled',
|
||||||
|
|
||||||
|
/* Hardware */
|
||||||
|
'dom.vr.enabled',
|
||||||
|
'media.ondevicechange.enabled',
|
||||||
|
|
||||||
|
/* Audio + Video */
|
||||||
|
'dom.webaudio.enabled',
|
||||||
|
'media.autoplay.enabled',
|
||||||
|
|
||||||
|
/* Forms */
|
||||||
|
'browser.formfill.enable',
|
||||||
|
'signon.autofillForms',
|
||||||
|
'signon.formlessCapture.enabled',
|
||||||
|
|
||||||
|
/* HTTPS */
|
||||||
|
'security.cert_pinning.enforcement_level',
|
||||||
|
'security.family_safety.mode',
|
||||||
|
'security.mixed_content.use_hsts',
|
||||||
|
'security.OCSP.require',
|
||||||
|
'security.pki.sha1_enforcement_level',
|
||||||
|
'security.ssl.require_safe_negotiation',
|
||||||
|
'security.ssl.treat_unsafe_negotiation_as_broken',
|
||||||
|
'security.ssl3.dhe_rsa_aes_128_sha',
|
||||||
|
'security.ssl3.dhe_rsa_aes_256_sha',
|
||||||
|
'security.ssl3.ecdhe_ecdsa_aes_128_sha',
|
||||||
|
'security.ssl3.ecdhe_rsa_aes_128_sha',
|
||||||
|
'security.ssl3.rsa_aes_128_sha',
|
||||||
|
'security.ssl3.rsa_aes_256_sha',
|
||||||
|
'security.ssl3.rsa_des_ede3_sha',
|
||||||
|
'security.tls.enable_0rtt_data',
|
||||||
|
'security.tls.version.max',
|
||||||
|
'security.tls.version.min',
|
||||||
|
|
||||||
|
/* Plugins + Flash */
|
||||||
|
'plugin.default.state',
|
||||||
|
'plugin.defaultXpi.state',
|
||||||
|
'plugin.sessionPermissionNow.intervalInMinutes',
|
||||||
|
'plugin.state.flash',
|
||||||
|
|
||||||
|
/* unlikely to cause problems */
|
||||||
|
'browser.tabs.remote.allowLinkedWebInFileUriProcess',
|
||||||
|
'dom.popup_maximum',
|
||||||
|
'layout.css.visited_links_enabled',
|
||||||
|
'mathml.disabled',
|
||||||
|
'network.auth.subresource-img-cross-origin-http-auth-allow',
|
||||||
|
'network.http.redirection-limit',
|
||||||
|
'network.protocol-handler.external.ms-windows-store',
|
||||||
|
'privacy.trackingprotection.enabled',
|
||||||
|
'security.data_uri.block_toplevel_data_uri_navigations',
|
||||||
|
|
||||||
|
'last.one.without.comma'
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
// reset prefs that set the same value as FFs default value
|
||||||
|
let aTEMP = getMyList(ops);
|
||||||
|
myreset(aTEMP);
|
||||||
|
reapply(aTEMP);
|
||||||
|
|
||||||
|
const aBACKUP = getMyList(ops);
|
||||||
|
//console.log(aBACKUP.length, "user-set prefs from our list detected and their values stored.");
|
||||||
|
|
||||||
|
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) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
myArr = myArr.slice(0, parseInt(myArr.length/2));
|
||||||
|
aDbg = myArr;
|
||||||
|
if (myArr.length == 1) { found = true; break; }
|
||||||
|
}
|
||||||
|
reapply(aBACKUP);
|
||||||
|
myreset(myArr.slice(0, parseInt(myArr.length/2))); // reset half of the remaining prefs
|
||||||
|
}
|
||||||
|
reapply(aBACKUP);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
reapply(aBACKUP);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
||||||
119
updater.bat
119
updater.bat
@@ -3,7 +3,7 @@ TITLE ghacks user.js updater
|
|||||||
|
|
||||||
REM ## ghacks-user.js updater for Windows
|
REM ## ghacks-user.js updater for Windows
|
||||||
REM ## author: @claustromaniac
|
REM ## author: @claustromaniac
|
||||||
REM ## version: 4.2
|
REM ## version: 4.4
|
||||||
REM ## instructions: https://github.com/ghacksuserjs/ghacks-user.js/wiki/3.3-Updater-Scripts
|
REM ## instructions: https://github.com/ghacksuserjs/ghacks-user.js/wiki/3.3-Updater-Scripts
|
||||||
|
|
||||||
SET _myname=%~n0
|
SET _myname=%~n0
|
||||||
@@ -16,6 +16,7 @@ IF /I "%~1"=="-logp" (SET _log=1 & SET _logp=1)
|
|||||||
IF /I "%~1"=="-multioverrides" (SET _multi=1)
|
IF /I "%~1"=="-multioverrides" (SET _multi=1)
|
||||||
IF /I "%~1"=="-merge" (SET _merge=1)
|
IF /I "%~1"=="-merge" (SET _merge=1)
|
||||||
IF /I "%~1"=="-updatebatch" (SET _updateb=1)
|
IF /I "%~1"=="-updatebatch" (SET _updateb=1)
|
||||||
|
IF /I "%~1"=="-singlebackup" (SET _singlebackup=1)
|
||||||
SHIFT
|
SHIFT
|
||||||
GOTO parse
|
GOTO parse
|
||||||
:endparse
|
:endparse
|
||||||
@@ -30,7 +31,6 @@ IF DEFINED _updateb (
|
|||||||
DEL /F "[updated]!_myname!.bat.old"
|
DEL /F "[updated]!_myname!.bat.old"
|
||||||
CALL :message "Script updated^!"
|
CALL :message "Script updated^!"
|
||||||
TIMEOUT 3 >nul
|
TIMEOUT 3 >nul
|
||||||
CLS
|
|
||||||
GOTO begin
|
GOTO begin
|
||||||
)
|
)
|
||||||
REM ## Phase 1 ##
|
REM ## Phase 1 ##
|
||||||
@@ -41,15 +41,13 @@ IF DEFINED _updateb (
|
|||||||
REM Uncomment the next line and comment the powershell call for testing.
|
REM Uncomment the next line and comment the powershell call for testing.
|
||||||
REM COPY /B /V /Y "!_myname!.bat" "[updated]!_myname!.bat"
|
REM COPY /B /V /Y "!_myname!.bat" "[updated]!_myname!.bat"
|
||||||
(
|
(
|
||||||
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://github.com/ghacksuserjs/ghacks-user.js/raw/master/updater.bat', '[updated]!_myname!.bat')"
|
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/updater.bat', '[updated]!_myname!.bat')"
|
||||||
) >nul 2>&1
|
) >nul 2>&1
|
||||||
IF EXIST "[updated]!_myname!.bat" (
|
IF EXIST "[updated]!_myname!.bat" (
|
||||||
START /min CMD /C "[updated]!_myname!.bat" !_myparams!
|
START /min CMD /C "[updated]!_myname!.bat" !_myparams!
|
||||||
EXIT /B
|
|
||||||
) ELSE (
|
) ELSE (
|
||||||
CALL :message "Failed. Make sure PowerShell is allowed internet access."
|
CALL :message "Failed. Make sure PowerShell is allowed internet access."
|
||||||
TIMEOUT 120 >nul
|
TIMEOUT 120 >nul
|
||||||
EXIT /B
|
|
||||||
)
|
)
|
||||||
) ELSE (
|
) ELSE (
|
||||||
IF "!_myname!"=="[updated]" (
|
IF "!_myname!"=="[updated]" (
|
||||||
@@ -67,23 +65,24 @@ IF DEFINED _updateb (
|
|||||||
COPY /B /V /Y "!_myname!.bat" "!_myname:~9!.bat"
|
COPY /B /V /Y "!_myname!.bat" "!_myname:~9!.bat"
|
||||||
START CMD /C "!_myname:~9!.bat" !_myparams!
|
START CMD /C "!_myname:~9!.bat" !_myparams!
|
||||||
)
|
)
|
||||||
|
)
|
||||||
EXIT /B
|
EXIT /B
|
||||||
)
|
)
|
||||||
)
|
|
||||||
:begin
|
:begin
|
||||||
|
CLS
|
||||||
ECHO:
|
ECHO:
|
||||||
ECHO:
|
ECHO:
|
||||||
ECHO: ########################################
|
ECHO: ########################################
|
||||||
ECHO: #### user.js Updater for Windows ####
|
ECHO: #### user.js Updater for Windows ####
|
||||||
ECHO: #### by claustromaniac ####
|
ECHO: #### by claustromaniac ####
|
||||||
ECHO: #### v4.2 ####
|
ECHO: #### v4.4 ####
|
||||||
ECHO: ########################################
|
ECHO: ########################################
|
||||||
ECHO:
|
ECHO:
|
||||||
SET /A "_line=0"
|
SET /A "_line=0"
|
||||||
IF NOT EXIST user.js (
|
IF NOT EXIST user.js (
|
||||||
CALL :message "user.js not detected in the current directory."
|
CALL :message "user.js not detected in the current directory."
|
||||||
) ELSE (
|
) ELSE (
|
||||||
FOR /F "skip=1 tokens=1,2 delims=:" %%G IN (user.js) DO (
|
FOR /F "skip=1 tokens=1,* delims=:" %%G IN (user.js) DO (
|
||||||
SET /A "_line+=1"
|
SET /A "_line+=1"
|
||||||
IF !_line! GEQ 4 (GOTO exitloop)
|
IF !_line! GEQ 4 (GOTO exitloop)
|
||||||
IF !_line! EQU 1 (SET _name=%%H)
|
IF !_line! EQU 1 (SET _name=%%H)
|
||||||
@@ -91,15 +90,11 @@ IF NOT EXIST user.js (
|
|||||||
IF !_line! EQU 3 (SET _version=%%G)
|
IF !_line! EQU 3 (SET _version=%%G)
|
||||||
)
|
)
|
||||||
:exitloop
|
:exitloop
|
||||||
IF !_line! GEQ 4 (
|
IF NOT "!_name!"=="" (
|
||||||
IF /I NOT "!_name!"=="!_name:ghacks=!" (
|
IF /I NOT "!_name!"=="!_name:ghacks=!" (
|
||||||
CALL :message "ghacks user.js !_version:~2!,!_date!"
|
CALL :message "!_name! !_version:~2!,!_date!"
|
||||||
) ELSE (
|
) ELSE (CALL :message "Current user.js version not recognised.")
|
||||||
CALL :message "Current user.js version not recognised."
|
) ELSE (CALL :message "Current user.js version not recognised.")
|
||||||
)
|
|
||||||
) ELSE (
|
|
||||||
CALL :message "Current user.js version not recognised."
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
ECHO:
|
ECHO:
|
||||||
IF NOT DEFINED _ua (
|
IF NOT DEFINED _ua (
|
||||||
@@ -121,19 +116,14 @@ IF DEFINED _log (
|
|||||||
:log
|
:log
|
||||||
SET _log=2
|
SET _log=2
|
||||||
ECHO:##################################################################
|
ECHO:##################################################################
|
||||||
CALL :message "%date%, %time%"
|
ECHO: %date%, %time%
|
||||||
)
|
|
||||||
IF EXIST user.js.old.bak (DEL /F user.js.old.bak)
|
|
||||||
IF EXIST user.js (
|
|
||||||
IF EXIST user.js.bak (REN user.js.bak user.js.old.bak)
|
|
||||||
REN user.js user.js.bak
|
|
||||||
CALL :message "Current user.js file backed up."
|
|
||||||
)
|
)
|
||||||
|
IF EXIST user.js.new (DEL /F "user.js.new")
|
||||||
CALL :message "Retrieving latest user.js file from github repository..."
|
CALL :message "Retrieving latest user.js file from github repository..."
|
||||||
(
|
(
|
||||||
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://github.com/ghacksuserjs/ghacks-user.js/raw/master/user.js', 'user.js')"
|
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/ghacksuserjs/ghacks-user.js/master/user.js', 'user.js.new')"
|
||||||
) >nul 2>&1
|
) >nul 2>&1
|
||||||
IF EXIST user.js (
|
IF EXIST user.js.new (
|
||||||
IF DEFINED _multi (
|
IF DEFINED _multi (
|
||||||
FORFILES /P user.js-overrides /M *.js >nul 2>&1
|
FORFILES /P user.js-overrides /M *.js >nul 2>&1
|
||||||
IF NOT ERRORLEVEL 1 (
|
IF NOT ERRORLEVEL 1 (
|
||||||
@@ -141,45 +131,46 @@ IF EXIST user.js (
|
|||||||
CALL :message "Merging..."
|
CALL :message "Merging..."
|
||||||
COPY /B /V /Y user.js-overrides\*.js user-overrides-merged.js
|
COPY /B /V /Y user.js-overrides\*.js user-overrides-merged.js
|
||||||
CALL :merge user-overrides-merged.js
|
CALL :merge user-overrides-merged.js
|
||||||
COPY /B /V /Y user.js+user-overrides-merged.js user.js
|
COPY /B /V /Y user.js.new+user-overrides-merged.js user.js.new
|
||||||
CALL :merge user.js
|
CALL :merge user.js.new
|
||||||
) ELSE (
|
) ELSE (
|
||||||
CALL :message "Appending..."
|
CALL :message "Appending..."
|
||||||
COPY /B /V /Y user.js+"user.js-overrides\*.js" user.js
|
COPY /B /V /Y user.js.new+"user.js-overrides\*.js" user.js.new
|
||||||
)
|
)
|
||||||
) ELSE (CALL :message "No override files found.")
|
) ELSE (CALL :message "No override files found.")
|
||||||
ECHO:
|
|
||||||
) ELSE (
|
) ELSE (
|
||||||
IF EXIST "user-overrides.js" (
|
IF EXIST "user-overrides.js" (
|
||||||
COPY /B /V /Y user.js+"user-overrides.js" "user.js"
|
COPY /B /V /Y user.js.new+"user-overrides.js" "user.js.new"
|
||||||
IF DEFINED _merge (
|
IF DEFINED _merge (
|
||||||
CALL :message "Merging user-overrides.js..."
|
CALL :message "Merging user-overrides.js..."
|
||||||
CALL :merge user.js
|
CALL :merge user.js.new
|
||||||
) ELSE (
|
) ELSE (
|
||||||
CALL :message "user-overrides.js appended."
|
CALL :message "user-overrides.js appended."
|
||||||
)
|
)
|
||||||
) ELSE (CALL :message "user-overrides.js not found.")
|
) ELSE (CALL :message "user-overrides.js not found.")
|
||||||
ECHO:
|
|
||||||
)
|
)
|
||||||
CALL :message "Handling backups..."
|
IF EXIST user.js (
|
||||||
SET "changed="
|
FC user.js.new user.js >nul && SET "_changed=false" || SET "_changed=true"
|
||||||
IF EXIST user.js.bak (
|
|
||||||
FC user.js.bak user.js >nul && SET "changed=false" || SET "changed=true"
|
|
||||||
)
|
)
|
||||||
IF "!changed!"=="true" (
|
IF "!_changed!"=="true" (
|
||||||
IF EXIST user.js.old.bak DEL /F user.js.old.bak
|
CALL :message "Backing up..."
|
||||||
|
IF DEFINED _singlebackup (
|
||||||
|
MOVE /Y user.js user.js.bak >nul
|
||||||
|
) ELSE (
|
||||||
|
MOVE /Y user.js "user-backup-!date:/=-!_!time::=.!.js" >nul
|
||||||
|
)
|
||||||
|
REN user.js.new user.js
|
||||||
CALL :message "Update complete."
|
CALL :message "Update complete."
|
||||||
) ELSE (
|
) ELSE (
|
||||||
IF "!changed!"=="false" (
|
IF "!_changed!"=="false" (
|
||||||
DEL /F user.js.bak
|
DEL /F user.js.new >nul
|
||||||
IF EXIST user.js.old.bak REN user.js.old.bak user.js.bak
|
|
||||||
CALL :message "Update completed without changes."
|
CALL :message "Update completed without changes."
|
||||||
) ELSE (CALL :message "Update complete.")
|
|
||||||
)
|
|
||||||
ECHO:
|
|
||||||
) ELSE (
|
) ELSE (
|
||||||
IF EXIST user.js.bak (REN user.js.bak user.js)
|
REN user.js.new user.js
|
||||||
IF EXIST user.js.old.bak (REN user.js.old.bak user.js.bak)
|
CALL :message "Update complete."
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) ELSE (
|
||||||
CALL :message "Update failed. Make sure PowerShell is allowed internet access."
|
CALL :message "Update failed. Make sure PowerShell is allowed internet access."
|
||||||
ECHO: No changes were made.
|
ECHO: No changes were made.
|
||||||
)
|
)
|
||||||
@@ -200,27 +191,27 @@ REM ############ Merge function ############
|
|||||||
:merge
|
:merge
|
||||||
SETLOCAL DisableDelayedExpansion
|
SETLOCAL DisableDelayedExpansion
|
||||||
(
|
(
|
||||||
FOR /F "tokens=1,* delims=," %%G IN ('FINDSTR /B /I /C:"user_pref" "%~1"') DO (SET "%%G=%%H")
|
FOR /F tokens^=2^,^*^ delims^=^'^" %%G IN ('FINDSTR /B /R /C:"user_pref.*\)[ ]*;" "%~1"') DO (IF NOT "%%H"=="" (SET "%%G=%%H"))
|
||||||
FOR /F "tokens=1,* delims=:" %%I IN ('FINDSTR /N "^" "%~1"') DO (
|
FOR /F "tokens=1,* delims=:" %%I IN ('FINDSTR /N "^" "%~1"') DO (
|
||||||
IF ""=="%%J" (
|
SET "_temp=%%J"
|
||||||
ECHO:
|
SETLOCAL EnableDelayedExpansion
|
||||||
|
IF NOT "!_temp:~0,9!"=="user_pref" (
|
||||||
|
ENDLOCAL & ECHO:%%J
|
||||||
) ELSE (
|
) ELSE (
|
||||||
FOR /F "delims=," %%K IN ("%%J") DO (
|
IF "!_temp:;=!"=="!_temp!" (
|
||||||
IF NOT [user_pref("_user.js.parrot"]==[%%K] (
|
ENDLOCAL & ECHO:%%J
|
||||||
|
) ELSE (
|
||||||
|
ENDLOCAL
|
||||||
|
FOR /F tokens^=2^ delims^=^'^" %%K IN ("%%J") DO (
|
||||||
|
IF NOT "_user.js.parrot"=="%%K" (
|
||||||
IF DEFINED %%K (
|
IF DEFINED %%K (
|
||||||
SETLOCAL EnableDelayedExpansion
|
SETLOCAL EnableDelayedExpansion
|
||||||
FOR /F "delims=" %%L IN ("!%%K!") DO (
|
FOR /F "delims=" %%L IN ("!%%K!") DO (
|
||||||
ENDLOCAL
|
ENDLOCAL & ECHO:user_pref("%%K"%%L
|
||||||
IF NOT "%%L"=="ALREADY MERGED" (
|
SET "%%K="
|
||||||
ECHO:%%K,%%L
|
|
||||||
SET "%%K=ALREADY MERGED"
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
) ELSE (
|
) ELSE (ECHO:%%J)
|
||||||
ECHO:%%J
|
|
||||||
)
|
|
||||||
) ELSE (
|
|
||||||
ECHO:%%J
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -231,7 +222,7 @@ ENDLOCAL
|
|||||||
GOTO :EOF
|
GOTO :EOF
|
||||||
REM ############### Help ##################
|
REM ############### Help ##################
|
||||||
:showhelp
|
:showhelp
|
||||||
MODE 80,43
|
MODE 80,46
|
||||||
CLS
|
CLS
|
||||||
CALL :message "Available arguments (case-insensitive):"
|
CALL :message "Available arguments (case-insensitive):"
|
||||||
CALL :message " -log"
|
CALL :message " -log"
|
||||||
@@ -239,7 +230,7 @@ ECHO: Write the console output to a logfile (user.js-update-log.txt)
|
|||||||
CALL :message " -logP"
|
CALL :message " -logP"
|
||||||
ECHO: Like -log, but also open the logfile after updating.
|
ECHO: Like -log, but also open the logfile after updating.
|
||||||
CALL :message " -merge"
|
CALL :message " -merge"
|
||||||
ECHO: Merge overrides instead of appending them. One-line comments and
|
ECHO: Merge overrides instead of appending them. Single-line comments and
|
||||||
ECHO: _user.js.parrot lines are appended normally. Overrides for inactive
|
ECHO: _user.js.parrot lines are appended normally. Overrides for inactive
|
||||||
ECHO: user.js prefs will be appended. When -Merge and -MultiOverrides are used
|
ECHO: user.js prefs will be appended. When -Merge and -MultiOverrides are used
|
||||||
ECHO: together, a user-overrides-merged.js file is also generated in the root
|
ECHO: together, a user-overrides-merged.js file is also generated in the root
|
||||||
@@ -254,11 +245,13 @@ ECHO: instead of the default user-overrides.js file. Files are appended in
|
|||||||
ECHO: alphabetical order.
|
ECHO: alphabetical order.
|
||||||
CALL :message " -unattended"
|
CALL :message " -unattended"
|
||||||
ECHO: Run without user input.
|
ECHO: Run without user input.
|
||||||
|
CALL :message " -singleBackup"
|
||||||
|
ECHO: Use a single backup file and overwrite it on new updates, instead of
|
||||||
|
ECHO: cumulative backups. This was the default behaviour before v4.3.
|
||||||
CALL :message " -updatebatch"
|
CALL :message " -updatebatch"
|
||||||
ECHO: Update the script itself on execution, before the normal routine.
|
ECHO: Update the script itself on execution, before the normal routine.
|
||||||
CALL :message ""
|
CALL :message ""
|
||||||
PAUSE
|
PAUSE
|
||||||
CLS
|
|
||||||
MODE 80,25
|
MODE 80,25
|
||||||
GOTO :begin
|
GOTO :begin
|
||||||
REM #####################################
|
REM #####################################
|
||||||
|
|||||||
Reference in New Issue
Block a user