troubleshooter.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*** ghacks-user.js troubleshooter.js v1.6.1 ***/
  2. (function() {
  3. if ("undefined" === typeof(Services)) return alert('about:config needs to be the active tab!');
  4. const aPREFS = [
  5. /* known culprits */
  6. 'network.cookie.cookieBehavior',
  7. 'network.http.referer.XOriginPolicy',
  8. 'privacy.firstparty.isolate',
  9. 'privacy.resistFingerprinting',
  10. 'security.mixed_content.block_display_content',
  11. 'svg.disabled',
  12. /* Storage + Cache */
  13. 'browser.cache.offline.enable',
  14. 'dom.indexedDB.enabled',
  15. 'dom.storage.enabled',
  16. 'browser.storageManager.enabled',
  17. 'dom.storageManager.enabled',
  18. /* Workers, Web + Push Notifications */
  19. 'dom.caches.enabled',
  20. 'dom.push.connection.enabled',
  21. 'dom.push.enabled',
  22. 'dom.push.serverURL',
  23. 'dom.serviceWorkers.enabled',
  24. 'dom.webnotifications.enabled',
  25. 'dom.webnotifications.serviceworker.enabled',
  26. /* Fonts */
  27. 'browser.display.use_document_fonts',
  28. 'font.blacklist.underline_offset',
  29. 'gfx.downloadable_fonts.woff2.enabled',
  30. 'gfx.font_rendering.graphite.enabled',
  31. 'gfx.font_rendering.opentype_svg.enabled',
  32. 'layout.css.font-loading-api.enabled',
  33. /* Misc */
  34. 'browser.link.open_newwindow.restriction',
  35. 'canvas.capturestream.enabled',
  36. 'dom.event.clipboardevents.enabled',
  37. 'dom.event.contextmenu.enabled',
  38. 'dom.IntersectionObserver.enabled',
  39. 'dom.popup_allowed_events',
  40. 'full-screen-api.enabled',
  41. 'geo.wifi.uri',
  42. 'intl.accept_languages',
  43. 'javascript.options.asmjs',
  44. 'javascript.options.wasm',
  45. 'permissions.default.shortcuts',
  46. 'security.csp.experimentalEnabled',
  47. /* Hardware */
  48. 'dom.vr.enabled',
  49. 'media.ondevicechange.enabled',
  50. /* Audio + Video */
  51. 'dom.webaudio.enabled',
  52. 'media.autoplay.enabled',
  53. 'media.autoplay.default', // FF63+
  54. /* Forms */
  55. 'browser.formfill.enable',
  56. 'signon.autofillForms',
  57. 'signon.formlessCapture.enabled',
  58. /* HTTPS */
  59. 'security.cert_pinning.enforcement_level',
  60. 'security.family_safety.mode',
  61. 'security.OCSP.require',
  62. 'security.pki.sha1_enforcement_level',
  63. 'security.ssl.require_safe_negotiation',
  64. 'security.ssl.treat_unsafe_negotiation_as_broken',
  65. 'security.ssl3.dhe_rsa_aes_128_sha',
  66. 'security.ssl3.dhe_rsa_aes_256_sha',
  67. 'security.ssl3.ecdhe_ecdsa_aes_128_sha',
  68. 'security.ssl3.ecdhe_rsa_aes_128_sha',
  69. 'security.ssl3.rsa_aes_128_sha',
  70. 'security.ssl3.rsa_aes_256_sha',
  71. 'security.ssl3.rsa_des_ede3_sha',
  72. 'security.tls.enable_0rtt_data',
  73. 'security.tls.version.max',
  74. 'security.tls.version.min',
  75. /* Plugins + Flash */
  76. 'plugin.default.state',
  77. 'plugin.defaultXpi.state',
  78. 'plugin.sessionPermissionNow.intervalInMinutes',
  79. 'plugin.state.flash',
  80. /* unlikely to cause problems */
  81. 'browser.tabs.remote.allowLinkedWebInFileUriProcess',
  82. 'dom.popup_maximum',
  83. 'layout.css.visited_links_enabled',
  84. 'mathml.disabled',
  85. 'network.auth.subresource-http-auth-allow',
  86. 'network.http.redirection-limit',
  87. 'network.protocol-handler.external.ms-windows-store',
  88. 'privacy.trackingprotection.enabled',
  89. 'security.data_uri.block_toplevel_data_uri_navigations',
  90. 'last.one.without.comma'
  91. ]
  92. // any runtime-set pref that everyone will have and that can be safely reset
  93. const oFILLER = { type: 64, name: 'app.update.lastUpdateTime.browser-cleanup-thumbnails', value: 1580000000 };
  94. function getMyList(arr) {
  95. const aRet = [];
  96. for (const sPname of arr) {
  97. if (Services.prefs.prefHasUserValue(sPname)) {
  98. const ptype = Services.prefs.getPrefType(sPname);
  99. switch (ptype) {
  100. case 32: // string (see https://dxr.mozilla.org/mozilla-central/source/modules/libpref/nsIPrefBranch.idl#31)
  101. aRet.push({'type':ptype,'name':sPname,'value':Services.prefs.getCharPref(sPname)});
  102. break;
  103. case 64: // int
  104. aRet.push({'type':ptype,'name':sPname,'value':Services.prefs.getIntPref(sPname)});
  105. break;
  106. case 128: // boolean
  107. aRet.push({'type':ptype,'name':sPname,'value':Services.prefs.getBoolPref(sPname)});
  108. break;
  109. default:
  110. console.log("error detecting pref-type for '"+sPname+"' !");
  111. }
  112. }
  113. }
  114. return aRet;
  115. }
  116. function reapply(arr) {
  117. for (const oPref of arr) {
  118. switch (oPref.type) {
  119. case 32: // string
  120. Services.prefs.setCharPref(oPref.name, oPref.value);
  121. break;
  122. case 64: // int
  123. Services.prefs.setIntPref(oPref.name, oPref.value);
  124. break;
  125. case 128: // boolean
  126. Services.prefs.setBoolPref(oPref.name, oPref.value);
  127. break;
  128. default:
  129. console.log("error re-appyling value for '"+oPref.name+"' !"); // should never happen
  130. }
  131. }
  132. }
  133. function myreset(arr) {
  134. for (const oPref of arr) Services.prefs.clearUserPref(oPref.name);
  135. }
  136. function resetAllMatchingDefault(arr) {
  137. const aTmp = getMyList(arr);
  138. myreset(aTmp);
  139. reapply(aTmp);
  140. }
  141. function _main(aALL) {
  142. const _h = (arr) => Math.ceil(arr.length/2);
  143. let aTmp = aALL, aDbg = aALL;
  144. reapply(aALL);
  145. myreset(aTmp.slice(0, _h(aTmp)));
  146. while (aTmp.length) {
  147. alert("NOW TEST AGAIN !");
  148. if (confirm("if the problem still exists click OK, otherwise click cancel.")) {
  149. aTmp = aTmp.slice(_h(aTmp));
  150. } else {
  151. aTmp = aTmp.slice(0, _h(aTmp));
  152. aDbg = aTmp; // update narrowed down list
  153. if (aDbg.length == 1) break;
  154. }
  155. reapply(aALL);
  156. myreset(aTmp.slice(0, _h(aTmp))); // reset half of the remaining prefs
  157. }
  158. reapply(aALL);
  159. if (aDbg.length == 1) return alert("narrowed it down to:\n\n"+aDbg[0].name+"\n");
  160. if (aDbg.length == aALL.length) {
  161. 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";
  162. 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";
  163. msg += "In case it's the latter, the script can add a dummy pref and you can try again - Try again?";
  164. if (confirm(msg)) return _main([...aALL, oFILLER]);
  165. } else if (aDbg.length > 10 && confirm("Narrowed it down to "+aDbg.length+" prefs. Try narrowing it down further?")) {
  166. return _main(aDbg.reverse());
  167. }
  168. alert("Narrowed it down to "+ aDbg.length.toString() +" prefs, check the console ...");
  169. console.log("The problem is caused by 2 or more of these prefs:");
  170. for (const oPref of aDbg) console.log(oPref.name);
  171. }
  172. resetAllMatchingDefault(aPREFS); // reset user-set prefs matching FFs default value
  173. const aBAK = getMyList(aPREFS);
  174. //console.log(aBAK.length, "user-set prefs from our list detected and their values stored.");
  175. focus();
  176. myreset(aBAK);
  177. 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.")) {
  178. reapply(aBAK);
  179. return;
  180. }
  181. _main(aBAK);
  182. })();