Dear serious and humorless Internet surfers

The battleground for flame wars, off-topic derailments and spurious madness.
Post Reply
barbaz
Senior Member
Posts: 10847
Joined: Sat Aug 03, 2013 5:45 pm

Dear serious and humorless Internet surfers

Post by barbaz »

It's that time of year when people like to give misinformation and play tricks on people... including on websites... and you don't like that, right? Want to tell websites you prefer not to deal with such awful shenanigans?

This addon used to provide that feature, however it's obsolete, reportedly not working with Firefox > 11. It appears to have no license associated with it, so I've decided to just grab some of the code and throw together a revived version. Here is the result. Just put these two files in the root of a new .zip file, rename the .zip to .xpi, and drag it into your browser window.

bootstrap.js

Code: Select all

const Cc=Components.classes, Ci=Components.interfaces, Cu=Components.utils;

Cu.import("resource://gre/modules/Services.jsm");

var dnfns = {

  prefName: "privacy.donotfoolheader.enabled",

  get enabled() {
    try {
      return Services.prefs.getBoolPref(dnfns.prefName);
    }
    catch(e) {
      Cu.reportError('Do Not Fool: caught exception: '+e);
      return false;
    }
  },

  /**
   * observer which will inject DNF into each request depending on the pref
   **/
  observe: function(subject, data) {
    if (dnfns.enabled) {
      let httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
      httpChannel.setRequestHeader("DNF", "1", false);
    }
  },

};

//
function startup(data, reason) {
  Services.obs.addObserver(dnfns, "http-on-modify-request", false);

  // set up default pref
  let dpb = Services.prefs.getDefaultBranch(null);
  dpb.setBoolPref(dnfns.prefName, false);
}

function shutdown(data, reason) {
  Services.obs.removeObserver(dnfns, "http-on-modify-request", false);
}

// unneeded boilerplate
function install() {}
function uninstall() {}
install.rdf

Code: Select all

<?xml version="1.0"?>
 
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
 
  <Description about="urn:mozilla:install-manifest">
    <em:id>do-not-fool-revived@11522914.none</em:id>
    <em:version>1.5</em:version>
    <em:type>2</em:type>
    <em:bootstrap>true</em:bootstrap>

    <!--firefox-->
    <em:targetApplication>
      <Description>
        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
        <em:minVersion>14.0</em:minVersion>
        <em:maxVersion>28.*</em:maxVersion>
      </Description>
    </em:targetApplication>

    <!--pale moon-->
    <em:targetApplication>
      <Description>
        <em:id>{8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}</em:id>
        <em:minVersion>14.0</em:minVersion>
        <em:maxVersion>99.*</em:maxVersion>
      </Description>
    </em:targetApplication>

    <!--seamonkey-->
    <em:targetApplication>
      <Description>
        <em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
        <em:minVersion>2.11</em:minVersion>
        <em:maxVersion>2.*</em:maxVersion>
      </Description>
    </em:targetApplication>

    <!--generic toolkit-->
    <em:targetApplication>
      <Description>
        <em:id>toolkit@mozilla.org</em:id>
        <em:minVersion>14.0</em:minVersion>
        <em:maxVersion>99.*</em:maxVersion>
      </Description>
    </em:targetApplication>

    <!-- Front end metadata -->
    <em:name>Do Not Fool, Revived</em:name>
    <em:description>Adds the option to send websites a Do-Not-Fool header (DNF: 1) with requests.

To enable this functionality go to about:config and set privacy.donotfoolheader.enabled to true.

Original addon: https://addons.mozilla.org/addon/do-not-fool/</em:description>
    <em:creator>11522914</em:creator>
    <em:contributor>Zbigniew Braniecki (original addon)</em:contributor>
  </Description>
</RDF>
Tested against PaleMoon 24.6.2 but should work in all browsers based on Gecko 14 and later.

Note that I did not port the UI, you need to manually go to about:config and set privacy.donotfoolheader.enabled to true to start sending the Do-Not-Fool header; also, if you disable or remove this addon, the default preference doesn't disappear without a browser restart.

You're welcome.
*Always* check the changelogs BEFORE updating that important software!
-
Post Reply