瀏覽代碼

Remove exclude domains option

simov 8 年之前
父節點
當前提交
4319e84e6e
共有 4 個文件被更改,包括 0 次插入145 次删除
  1. 0 11
      README.md
  2. 0 33
      background/background.js
  3. 0 80
      content/options.js
  4. 0 21
      css/options.css

+ 0 - 11
README.md

@@ -38,7 +38,6 @@
 - [Advanced Options](#advanced-options)
   - [Add Origin](#add-origin)
   - [Add All Origins](#add-all-origins)
-  - [Exclude Domains](#exclude-domains)
   - [Header Detection](#header-detection)
   - [Path Matching](#path-matching)
   - [Remove Origin](#remove-origin)
@@ -156,16 +155,6 @@ Alternatively you can use the `Allow All` button.
 
 > Note that the remote origins should either provide a valid HTTP header (see [Header Detection](#header-detection)) and/or valid URL path (see [Path Matching](#path-matching)). Otherwise you'll have to add the origin explicitly and set its [Path Matching](#path-matching) regular expression.
 
-## Exclude Domains
-
-When you enable the extension for all origins, a new `Excluded Domains` section will become available in the options page.
-
-When the extension is enabled for all origins, it will try to inject itself into all pages with URLs ending with markdown file extension using the [Path Matching](#path-matching) for the `*://*` origin.
-
-However a few websites are known to serve pages with URLs ending with markdown file extension, but instead of a raw markdown they serve a rendered HTML there. For example: https://github.com/simov/markdown-viewer/blob/master/README.md
-
-When you enable the extension for all origins you get a list of domains excluded by default: `bitbucket.org`, `getcomposer.org`, `github.com`, `gitlab.com`, however you can extend/modify that list as you want.
-
 ## Header Detection
 
 When this option is enabled the extension will check for the `text/markdown` and `text/x-markdown` *content-type* header before trying to match the path:

+ 0 - 33
background/background.js

@@ -19,12 +19,6 @@ var defaults = {
   origins: {
     'file://': match
   },
-  exclude: [
-    'bitbucket.org',
-    'getcomposer.org',
-    'github.com',
-    'gitlab.com',
-  ]
 }
 Object.keys(md).forEach((compiler) => {
   defaults[compiler] = md[compiler].defaults
@@ -82,10 +76,6 @@ chrome.storage.sync.get((res) => {
   if (options.content.mathjax === undefined) {
     options.content.mathjax = false
   }
-  // v3.2 -> v3.3
-  if (options.exclude === undefined) {
-    options.exclude = defaults.exclude
-  }
 
   // reload extension bug
   chrome.permissions.getAll((permissions) => {
@@ -159,12 +149,6 @@ chrome.tabs.onUpdated.addListener((id, info, tab) => {
         return
       }
 
-      if (state.origins['*://*'] &&
-        state.exclude.some((domain) => domain === win.location.host)) {
-        // excluded domain
-        return
-      }
-
       if (state.header && /text\/(?:x-)?markdown/i.test(win.contentType)) {
         inject(id)
       }
@@ -278,23 +262,6 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
     sendResponse()
   }
 
-  // options domains
-  else if (req.message === 'domain.add') {
-    state.exclude.push(req.domain)
-    set({exclude: state.exclude})
-    sendResponse()
-  }
-  else if (req.message === 'domain.remove') {
-    state.exclude.splice(req.index, 1)
-    set({exclude: state.exclude})
-    sendResponse()
-  }
-  else if (req.message === 'domain.defaults') {
-    state.exclude = defaults.exclude.slice()
-    set({exclude: state.exclude})
-    sendResponse()
-  }
-
   return true
 })
 

+ 0 - 80
content/options.js

@@ -3,13 +3,11 @@ var defaults = {
   // storage
   origins: {},
   header: false,
-  exclude: [],
   // static
   protocols: ['https', 'http', '*'],
   // UI
   protocol: 'https',
   origin: '',
-  domain: '',
   timeout: null,
   file: true,
 }
@@ -81,39 +79,6 @@ var events = {
       chrome.permissions.request({origins: [origin + '/*']})
     },
   },
-
-  domain: {
-    name: (e) => {
-      state.domain = e.target.value
-    },
-
-    add: () => {
-      var domain = state.domain.replace(/.*:\/\/([^/]+).*/i, '$1')
-      if (!domain) {
-        return
-      }
-      if (state.exclude.includes(domain)) {
-        return
-      }
-      chrome.runtime.sendMessage({
-        message: 'domain.add',
-        domain,
-      }, init)
-    },
-
-    remove: (domain) => () => {
-      chrome.runtime.sendMessage({
-        message: 'domain.remove',
-        index: state.exclude.indexOf(domain),
-      }, init)
-    },
-
-    defaults: () => {
-      chrome.runtime.sendMessage({
-        message: 'domain.defaults',
-      }, init)
-    },
-  },
 }
 
 chrome.extension.isAllowedFileSchemeAccess((isAllowedAccess) => {
@@ -254,50 +219,5 @@ m.mount(document.querySelector('main'), {
           )
         )
       ),
-
-      // excluded domains
-      (state.origins['*://*'] || null) &&
-      m('.bs-callout m-exclude',
-        m('h4.mdc-typography--headline', 'Excluded Domains'),
-
-        m('.mdc-textfield m-textfield',
-          m('input.mdc-textfield__input', {
-            type: 'text',
-            value: state.domain,
-            onchange: events.domain.name,
-            placeholder: 'github.com'
-          })
-        ),
-        m('button.mdc-button mdc-button--raised m-button', {
-          oncreate: oncreate.ripple,
-          onclick: events.domain.add
-          },
-          'Add'
-        ),
-        m('button.mdc-button mdc-button--raised m-button', {
-          oncreate: oncreate.ripple,
-          onclick: events.domain.defaults
-          },
-          'Defaults'
-        ),
-
-        m('ul.mdc-elevation--z2 m-list',
-          state.exclude.sort().map((domain) =>
-            m('li',
-              m('span', domain),
-              (origin !== 'file://' || null) &&
-              m('span',
-                m('button.mdc-button', {
-                  oncreate: oncreate.ripple,
-                  onclick: events.domain.remove(domain),
-                  title: 'Remove'
-                  },
-                  m('i.material-icons icon-remove')
-                )
-              )
-            )
-          )
-        ),
-      )
     )
 })

+ 0 - 21
css/options.css

@@ -227,24 +227,3 @@ footer a:nth-of-type(2):before {
 .m-origins .m-list li > *:nth-child(2) { width: 30%; }
 .m-origins .m-list li > *:nth-child(3) { width: 54%; }
 .m-origins .m-list li > *:nth-child(4) { width: 9%; text-align: right; }
-
-
-/*excluded domains*/
-.m-exclude h4 {
-  line-height: 36px;
-  float: left;
-  margin: 0 180px 20px 0 !important;
-}
-.m-exclude .m-textfield {
-  float: left;
-  width: 400px;
-  margin: 0 10px 0 0 !important;
-}
-.m-exclude > .m-button {
-  float: left;
-}
-.m-exclude button:nth-of-type(2) {
-  float: right;
-}
-.m-exclude .m-list li > *:nth-child(1) { width: 95% !important; }
-.m-exclude .m-list li > *:nth-child(2) { width: 5%; text-align: right; }