~harmless/security.txt

d79a44851f7ba413f0e0e0fcf6595c6c71fe6c2c — Travis Paul 1 year, 8 months ago d8c85c9
Work around browser quirks in Chrome/Edge
M Gruntfile.js => Gruntfile.js +10 -2
@@ 60,7 60,7 @@ module.exports = function(grunt) {
    }
  });

  grunt.registerTask('manifests', 'Combine manifest.json files', function () {
  grunt.registerTask('manifests', 'Combine manifest.json files', () => {
    const {merge} = require('lodash/object');
    function rmNotes(obj) {
      const notesRegExp = new RegExp('^_notes_');


@@ 94,6 94,13 @@ module.exports = function(grunt) {
    });
  });

  grunt.registerTask('quirks', 'Append browser global to work around quirks', () => {
    const {appendFileSync} = require('fs');
    browsers.forEach((browser) => {
      appendFileSync(`build/${browser}/js/global.js`, `\nconst BROWSER_QUIRKS = '${browser}';`);
    });
  });

  grunt.registerTask('default', [
    'jshint:extension',
    'jshint:node',


@@ 101,6 108,7 @@ module.exports = function(grunt) {
    'mkdir',
    'manifests',
    'copy',
    'copy:polyfill'
    'copy:polyfill',
    'quirks'
  ]);
};

A src/img/info.16.png => src/img/info.16.png +0 -0
A src/img/info.19.png => src/img/info.19.png +0 -0
A src/img/info.24.png => src/img/info.24.png +0 -0
A src/img/info.32.png => src/img/info.32.png +0 -0
A src/img/info.48.png => src/img/info.48.png +0 -0
A src/img/info.96.png => src/img/info.96.png +0 -0
A src/img/info.inactive.16.png => src/img/info.inactive.16.png +0 -0
A src/img/info.inactive.19.png => src/img/info.inactive.19.png +0 -0
A src/img/info.inactive.24.png => src/img/info.inactive.24.png +0 -0
A src/img/info.inactive.32.png => src/img/info.inactive.32.png +0 -0
A src/img/info.inactive.48.png => src/img/info.inactive.48.png +0 -0
A src/img/info.inactive.96.png => src/img/info.inactive.96.png +0 -0
A src/img/info.svg => src/img/info.svg +23 -0
@@ 0,0 1,23 @@
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48">
<defs>
<radialGradient id="b" gradientUnits="userSpaceOnUse" cy="28.46" cx="26.54" gradientTransform="matrix(1.156 .005968 -.005968 1.261 -4.845 -7.341)" r="22.38">
<stop stop-color="#9cbcde" offset="0"/>
<stop stop-color="#204a87" offset="1"/>
</radialGradient>
<radialGradient id="a" gradientUnits="userSpaceOnUse" cy="17.68" cx="-9.5" gradientTransform="matrix(4.446 0 0 6.866 67.3-104.4)" r="8.75">
<stop stop-color="#fff" offset="0"/>
<stop stop-color="#b8b8b8" offset="1"/>
</radialGradient>
<radialGradient id="c" gradientUnits="userSpaceOnUse" cy="42" cx="31.55" gradientTransform="matrix(1 0 0 .3333 -7.55 28)" r="18">
<stop offset="0"/>
<stop stop-opacity="0" offset="1"/>
</radialGradient>
</defs>
<ellipse opacity="0.63" rx="18" ry="6" cy="42" cx="24" fill="url(#c)"/>
<circle cy="24" cx="24" r="21.5" fill="#204a87"/>
<g stroke-linejoin="round" stroke="#fff">
<circle stroke-opacity=".94" r="18.6" cy="24" cx="24" stroke-width="2.5" fill="url(#b)"/>
<path stroke-width=".8" d="m21.5 19.4h5v15.9h-5v-15.9zm0-6.6h5v4.2h-5v-4.2z" stroke-opacity=".78" fill="url(#a)"/>
</g>
</svg>
\ No newline at end of file

M src/js/background.js => src/js/background.js +30 -3
@@ 1,4 1,4 @@
/* globals i18n */
/* globals i18n, BROWSER_QUIRKS */

const httpRegExp = new RegExp('^http');



@@ 81,7 81,6 @@ function fetchFiles(tabId, tab) {
      }, fetchError);

    }, fetchError).finally(() => {
      console.log('finalResults', finalResults);

      let title = i18n((humansTxtCheck) ?
        'found_nothing' : 'not_found_security_txt');


@@ 94,7 93,7 @@ function fetchFiles(tabId, tab) {
        title = i18n('found_security_and_humans_txt');
      }
      
      // XXX Need to change icons for Chrome/Edge bug with pageAction.hide()
      // Mote that we need to change icons for Chrome/Edge bug with pageAction.hide()
      // interesting enough, the bug doesn't impact Opera
      if (finalResults.security || finalResults.humans) {
        localStorage.setItem(finalResults.host, JSON.stringify(finalResults));


@@ 103,6 102,20 @@ function fetchFiles(tabId, tab) {
          tabId: tabId,
          popup: 'popup.html#' + finalResults.host
        });

        if (BROWSER_QUIRKS === 'chrome' || BROWSER_QUIRKS === 'edge') {
          browser.pageAction.setIcon({
            tabId: tabId,
            path: {
              '16': 'img/info.16.png',
              '19': 'img/info.19.png',
              '24': 'img/info.24.png',
              '32': 'img/info.32.png',
              '48': 'img/info.48.png',
              '96': 'img/info.96.png'
            }
          });
        }
      } else {
        localStorage.removeItem(finalResults.host);
        browser.pageAction.hide(tabId);


@@ 113,6 126,20 @@ function fetchFiles(tabId, tab) {
          // the extension will receive pageAction.onClicked events.
          popup: ''
        });

        if (BROWSER_QUIRKS === 'chrome' || BROWSER_QUIRKS === 'edge') {
          browser.pageAction.setIcon({
            tabId: tabId,
            path: {
              '16': 'img/info.inactive.16.png',
              '19': 'img/info.inactive.19.png',
              '24': 'img/info.inactive.24.png',
              '32': 'img/info.inactive.32.png',
              '48': 'img/info.inactive.48.png',
              '96': 'img/info.inactive.96.png'
            }
          });
        }
      }

      browser.pageAction.setTitle({

M src/manifest.chrome.json => src/manifest.chrome.json +8 -0
@@ 1,6 1,14 @@
{
  "_notes_chrome_style": "https://developer.chrome.com/extensions/manifest",
  "page_action": {
    "default_icon": {
      "16": "img/info.inactive.16.png",
      "19": "img/info.inactive.19.png",
      "24": "img/info.inactive.24.png",
      "32": "img/info.inactive.32.png",
      "48": "img/info.inactive.48.png",
      "96": "img/info.inactive.96.png"
    },
    "chrome_style": true
  },
  

M src/manifest.edge.json => src/manifest.edge.json +9 -0
@@ 1,9 1,18 @@
{
  "_notes_chrome_style": "https://developer.chrome.com/extensions/manifest",
  "page_action": {
    "default_icon": {
      "16": "img/info.inactive.16.png",
      "19": "img/info.inactive.19.png",
      "24": "img/info.inactive.24.png",
      "32": "img/info.inactive.32.png",
      "48": "img/info.inactive.48.png",
      "96": "img/info.inactive.96.png"
    },
    "chrome_style": true
  },
  
  "_notes_background": "https://github.com/mozilla/webextension-polyfill",
  "background": {
    "scripts": [
      "js/browser-polyfill.js",

M src/manifest.firefox.json => src/manifest.firefox.json +1 -0
@@ 19,6 19,7 @@

  "_notes_page_action": "https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Browser_styles",
  "page_action": {
    "default_icon": "img/info.svg",
    "browser_style": true
  }
}
\ No newline at end of file

M src/manifest.json => src/manifest.json +1 -12
@@ 28,18 28,7 @@
    "tabs",
    "storage"
  ],
  "page_action": {
    "default_icon": {
      "19": "img/19.png",
      "20": "img/20.png",
      "30": "img/30.png",
      "35": "img/35.png",
      "38": "img/38.png",
      "40": "img/40.png",
      "48": "img/48.png",
      "96": "img/96.png"
    }
  },
  "page_action": {},
  "background": {
    "persistent": false
  }

M src/manifest.opera.json => src/manifest.opera.json +9 -0
@@ 1,5 1,14 @@
{
  "_notes_page_action": "Opera doesn't suffer from the hide/show pageAction bug in Chrome/Edge",
  "page_action": {
    "default_icon": {
      "16": "img/info.16.png",
      "19": "img/info.19.png",
      "24": "img/info.24.png",
      "32": "img/info.32.png",
      "48": "img/info.48.png",
      "96": "img/info.96.png"
    },
    "chrome_style": true
  },