You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
5.6 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. /*******************************************************************************
  2. µMatrix - a Chromium browser extension to black/white list requests.
  3. Copyright (C) 2014 Raymond Hill
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see {http://www.gnu.org/licenses/}.
  14. Home: https://github.com/gorhill/uMatrix
  15. */
  16. /* global chrome */
  17. /******************************************************************************/
  18. var µMatrix = (function() {
  19. /******************************************************************************/
  20. var oneSecond = 1000;
  21. var oneMinute = 60 * oneSecond;
  22. var oneHour = 60 * oneMinute;
  23. var oneDay = 24 * oneHour;
  24. /******************************************************************************/
  25. var defaultUserAgentStrings = [
  26. '# http://www.useragentstring.com/pages/Chrome/',
  27. '# http://techblog.willshouse.com/2012/01/03/most-common-user-agents/',
  28. 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36',
  29. 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.1.17 (KHTML, like Gecko) Version/7.1 Safari/537.85.10',
  30. 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/600.1.25 (KHTML, like Gecko) Version/8.0 Safari/600.1.25',
  31. 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36',
  32. 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36',
  33. 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36',
  34. 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36'
  35. ].join('\n');
  36. /******************************************************************************/
  37. return {
  38. manifest: chrome.runtime.getManifest(),
  39. userSettings: {
  40. autoUpdate: false,
  41. clearBrowserCache: true,
  42. clearBrowserCacheAfter: 60,
  43. colorBlindFriendly: false,
  44. deleteCookies: false,
  45. deleteUnusedSessionCookies: false,
  46. deleteUnusedSessionCookiesAfter: 60,
  47. deleteLocalStorage: false,
  48. displayTextSize: '13px',
  49. externalHostsFiles: '',
  50. maxLoggedRequests: 50,
  51. popupCollapseDomains: false,
  52. popupCollapseSpecificDomains: {},
  53. popupHideBlacklisted: false,
  54. popupScopeLevel: 'domain',
  55. processBehindTheSceneRequests: false,
  56. processHyperlinkAuditing: true,
  57. processReferer: false,
  58. smartAutoReload: 'current',
  59. spoofUserAgent: false,
  60. spoofUserAgentEvery: 5,
  61. spoofUserAgentWith: defaultUserAgentStrings,
  62. statsFilters: {},
  63. subframeColor: '#cc0000',
  64. subframeOpacity: 100
  65. },
  66. clearBrowserCacheCycle: 0,
  67. updateAssetsEvery: 11 * oneDay + 1 * oneHour + 1 * oneMinute + 1 * oneSecond,
  68. firstUpdateAfter: 11 * oneMinute,
  69. nextUpdateAfter: 11 * oneHour,
  70. projectServerRoot: 'https://raw.githubusercontent.com/gorhill/umatrix/master/',
  71. pslPath: 'assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat',
  72. // permanent hosts files
  73. permanentHostsFiles: {
  74. // µMatrix
  75. 'assets/umatrix/blacklist.txt': {
  76. title: 'µMatrix hosts file'
  77. }
  78. },
  79. // list of live hosts files
  80. liveHostsFiles: {
  81. },
  82. // urls stats are kept on the back burner while waiting to be reactivated
  83. // in a tab or another.
  84. pageStats: {}, // TODO: rename
  85. // A map of redirects, to allow reverse lookup of redirects from landing
  86. // page, so that redirection can be reported to the user.
  87. redirectRequests: {},
  88. // tabs are used to redirect stats collection to a specific url stats
  89. // structure.
  90. pageUrlToTabId: {},
  91. tabIdToPageUrl: {},
  92. // page url => permission scope
  93. tMatrix: null,
  94. pMatrix: null,
  95. ubiquitousBlacklist: null,
  96. // various stats
  97. requestStats: new WebRequestStats(),
  98. cookieRemovedCounter: 0,
  99. localStorageRemovedCounter: 0,
  100. cookieHeaderFoiledCounter: 0,
  101. refererHeaderFoiledCounter: 0,
  102. hyperlinkAuditingFoiledCounter: 0,
  103. browserCacheClearedCounter: 0,
  104. storageQuota: chrome.storage.local.QUOTA_BYTES,
  105. storageUsed: 0,
  106. userAgentReplaceStr: '',
  107. userAgentReplaceStrBirth: 0,
  108. // record what chromium is doing behind the scene
  109. behindTheSceneURL: 'http://chromium-behind-the-scene/',
  110. behindTheSceneTabId: 0x7FFFFFFF,
  111. behindTheSceneMaxReq: 250,
  112. behindTheSceneScope: 'chromium-behind-the-scene',
  113. // Commonly encountered strings
  114. chromeExtensionURLPrefix: 'chrome-extension://',
  115. noopCSSURL: chrome.runtime.getURL('css/noop.css'),
  116. fontCSSURL: chrome.runtime.getURL('css/fonts/Roboto_Condensed/RobotoCondensed-Regular.ttf'),
  117. noopFunc: function(){},
  118. // so that I don't have to care for last comma
  119. dummy: 0
  120. };
  121. /******************************************************************************/
  122. })();
  123. /******************************************************************************/