user.js

mirror of https://github.com/arkenfox/user.js
Log | Files | Refs | README

troubleshooter.js (7072B)


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