summaryrefslogtreecommitdiff
path: root/bootstrap.js
blob: 7cdf6642283c495773784473a0308fedbc370fce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.

 GitHub Web Components Polyfill Add-on
 Copyright (c) 2020 JustOff. All rights reserved.

 Web Components Polyfills 
 Copyright (c) 2014-2020 The Polymer Project Authors. All rights reserved.
 This code may only be used under the BSD style license found at
 http://polymer.github.io/LICENSE.txt The complete set of authors may be found
 at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
 be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
 Google as part of the polymer project is also subject to an additional IP
 rights grant found at http://polymer.github.io/PATENTS.txt
*/

"use strict";

var Ci = Components.interfaces, Cu = Components.utils;

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

Cu.importGlobalProperties(["atob"]);

const polyfill = atob("KGZ1bmN0aW9uKCl7Cid1c2Ugc3RyaWN0Jzt2YXIgYWE9bmV3IFNldCgiYW5ub3RhdGlvbi14bWwgY29sb3ItcHJvZmlsZSBmb250LWZhY2UgZm9udC1mYWNlLXNyYyBmb250LWZhY2UtdXJpIGZvbnQtZmFjZS1mb3JtYXQgZm9udC1mYWNlLW5hbWUgbWlzc2luZy1nbHlwaCIuc3BsaXQoIiAiKSk7ZnVuY3Rpb24gZyhhKXt2YXIgYj1hYS5oYXMoYSk7YT0vXlthLXpdWy4wLTlfYS16XSotW1wtLjAtOV9hLXpdKiQvLnRlc3QoYSk7cmV0dXJuIWImJmF9ZnVuY3R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hfSk7emEoKTtCYSgpO2RvY3VtZW50Ll9fQ0VfaGFzUmVnaXN0cnk9ITA7dmFyIGN1c3RvbUVsZW1lbnRzPW5ldyBFKFgpO09iamVjdC5kZWZpbmVQcm9wZXJ0eSh3aW5kb3csImN1c3RvbUVsZW1lbnRzIix7Y29uZmlndXJhYmxlOiEwLGVudW1lcmFibGU6ITAsdmFsdWU6Y3VzdG9tRWxlbWVudHN9KX07Cn0pLmNhbGwodGhpcyk7");

const sha256 = "'sha256-S/zT4Ln6E7xGuKI45TJz8HEyEVXNDlfSIE2a0sgwuAM='";

var httpResponseObserver = {
  observe: function (subject, topic, data) {
    if ((topic == "http-on-examine-response" || topic == "http-on-examine-cached-response") &&
        subject instanceof Ci.nsIHttpChannel && subject.URI.host == "github.com" &&
        (subject.responseStatus == 200 || subject.responseStatus == 304)) {
      try {
        let ctype = subject.getResponseHeader("Content-Type").toLowerCase();
        if (ctype.indexOf("text/html") == -1 && ctype.indexOf("text/javascript") == -1) {
          return;
        }
      } catch (e) {}
      try {
        let csp = subject.getResponseHeader("Content-Security-Policy");
        csp = csp.replace("script-src ", "script-src " + sha256 + " ");
        csp = csp.replace("worker-src ", "worker-src github.githubassets.com ");
        subject.setResponseHeader("Content-Security-Policy", csp, false);
      } catch (e) {}
    }
  },
  QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference])
};

var deiObserver = {
  observe: function(subject, topic, data) {
    if (topic == "document-element-inserted" && subject instanceof Ci.nsIDOMDocument &&
        subject.defaultView && subject.defaultView == subject.defaultView.top &&
        subject.location.protocol == "https:" &&
        subject.location.hostname == "github.com" &&
        subject.contentType == "text/html") {
      let script = subject.createElement("script");
      script.textContent = polyfill;
      let heads = subject.documentElement.getElementsByTagName("head");
      if (heads.length && heads[0].firstElementChild) {
        heads[0].insertBefore(script, heads[0].firstElementChild);
      }
    }
  },
  QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference])
};

function startup(data, reason) {
  Services.obs.addObserver(httpResponseObserver, "http-on-examine-response", false);
  Services.obs.addObserver(httpResponseObserver, "http-on-examine-cached-response", false);
  Services.obs.addObserver(deiObserver, "document-element-inserted", false);
}

function shutdown(data, reason) {
  if (reason == APP_SHUTDOWN) {
    return;
  }
  Services.obs.removeObserver(deiObserver, "document-element-inserted", false);
  Services.obs.removeObserver(httpResponseObserver, "http-on-examine-cached-response", false);
  Services.obs.removeObserver(httpResponseObserver, "http-on-examine-response", false);
}

function install() {}

function uninstall() {}