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.

86 lines
2.5 KiB

  1. /*******************************************************************************
  2. uMatrix - a browser extension to block requests.
  3. Copyright (C) 2017-present 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/uBlock
  15. */
  16. 'use strict';
  17. /* global HTMLDocument, XMLDocument */
  18. // For background page, auxiliary pages, and content scripts.
  19. /******************************************************************************/
  20. if ( self.browser instanceof Object ) {
  21. self.chrome = self.browser;
  22. } else {
  23. self.browser = self.chrome;
  24. }
  25. /******************************************************************************/
  26. // https://bugzilla.mozilla.org/show_bug.cgi?id=1408996#c9
  27. var vAPI = self.vAPI; // jshint ignore:line
  28. // https://github.com/chrisaljoudi/uBlock/issues/464
  29. // https://github.com/chrisaljoudi/uBlock/issues/1528
  30. // A XMLDocument can be a valid HTML document.
  31. // https://github.com/gorhill/uBlock/issues/1124
  32. // Looks like `contentType` is on track to be standardized:
  33. // https://dom.spec.whatwg.org/#concept-document-content-type
  34. // https://forums.lanik.us/viewtopic.php?f=64&t=31522
  35. // Skip text/plain documents.
  36. if (
  37. (
  38. document instanceof HTMLDocument ||
  39. document instanceof XMLDocument &&
  40. document.createElement('div') instanceof HTMLDivElement
  41. ) &&
  42. (
  43. /^image\/|^text\/plain/.test(document.contentType || '') === false
  44. ) &&
  45. (
  46. self.vAPI instanceof Object === false || vAPI.nuTensor !== true
  47. )
  48. ) {
  49. vAPI = self.vAPI = { nuTensor: true };
  50. }
  51. /*******************************************************************************
  52. DO NOT:
  53. - Remove the following code
  54. - Add code beyond the following code
  55. Reason:
  56. - https://github.com/gorhill/uBlock/pull/3721
  57. - uMatrix never uses the return value from injected content scripts
  58. **/
  59. void 0;