diff --git a/background/style-manager.js b/background/style-manager.js index d772c59b..1af60bef 100644 --- a/background/style-manager.js +++ b/background/style-manager.js @@ -1,6 +1,6 @@ /* eslint no-eq-null: 0, eqeqeq: [2, "smart"] */ /* global createCache db calcStyleDigest db tryRegExp styleCodeEmpty styleSectionGlobal - getStyleWithNoCode msg prefs sync uuidv4 URLS */ + getStyleWithNoCode msg prefs sync URLS */ /* exported styleManager */ 'use strict'; @@ -716,4 +716,17 @@ const styleManager = (() => { return DUMMY_URL; } } + + function uuidv4() { + const seeds = crypto.getRandomValues(new Uint16Array(8)); + // 00001111-2222-M333-N444-555566667777 + seeds[3] = seeds[3] & 0x0FFF | 0x4000; // UUID version 4, M = 4 + seeds[4] = seeds[4] & 0x3FFF | 0x8000; // UUID variant 1, N = 8..0xB + return Array.from(seeds, hex4dashed).join(''); + } + + /** uuidv4 helper: converts to a 4-digit hex string and adds "-" at required positions */ + function hex4dashed(num, i) { + return (num + 0x10000).toString(16).slice(-4) + (i >= 1 && i <= 4 ? '-' : ''); + } })(); diff --git a/manifest.json b/manifest.json index 887160ee..faf9d0ca 100644 --- a/manifest.json +++ b/manifest.json @@ -40,7 +40,6 @@ "js/cache.js", "vendor/semver-bundle/semver.js", "vendor/db-to-cloud/db-to-cloud.min.js", - "vendor/uuid/uuid.min.js", "vendor/webext-launch-web-auth-flow/webext-launch-web-auth-flow.min.js", "background/token-manager.js", "background/sync.js", diff --git a/package-lock.json b/package-lock.json index 86c23d51..bb64deca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7827,11 +7827,6 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, - "uuid": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.1.0.tgz", - "integrity": "sha512-CI18flHDznR0lq54xBycOVmphdCYnQLKn8abKn7PXUiKUGdEd+/l9LWNJmugXel4hXq7S+RMNl34ecyC9TntWg==" - }, "v8-compile-cache": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz", diff --git a/package.json b/package.json index f1e83fea..5ede7b19 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "stylelint-bundle": "^8.0.0", "stylus-lang-bundle": "^0.54.5", "usercss-meta": "^0.9.0", - "uuid": "^8.1.0", "webext-launch-web-auth-flow": "^0.1.0" }, "devDependencies": { diff --git a/tools/build-vendor.js b/tools/build-vendor.js index 639a74ab..41279fb2 100644 --- a/tools/build-vendor.js +++ b/tools/build-vendor.js @@ -60,9 +60,6 @@ const files = { 'db-to-cloud': [ 'dist/db-to-cloud.min.js → db-to-cloud.min.js' ], - 'uuid': [ - 'dist/umd/uuidv4.min.js → uuid.min.js' - ], 'webext-launch-web-auth-flow': [ 'dist/webext-launch-web-auth-flow.min.js → webext-launch-web-auth-flow.min.js' ] diff --git a/vendor/uuid/LICENSE b/vendor/uuid/LICENSE deleted file mode 100644 index f8969d33..00000000 --- a/vendor/uuid/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2010-2020 Robert Kieffer and other contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/uuid/README.md b/vendor/uuid/README.md deleted file mode 100644 index 623fe75e..00000000 --- a/vendor/uuid/README.md +++ /dev/null @@ -1,5 +0,0 @@ -## uuid v8.1.0 - -Following files are copied from npm (node_modules): - -* uuid.min.js: dist\umd\uuidv4.min.js diff --git a/vendor/uuid/uuid.min.js b/vendor/uuid/uuid.min.js deleted file mode 100644 index 61da7182..00000000 --- a/vendor/uuid/uuid.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).uuidv4=e()}(this,(function(){"use strict";var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),e=new Uint8Array(16);function n(){if(!t)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(e)}for(var o=[],r=0;r<256;++r)o.push((r+256).toString(16).substr(1));return function(t,e,r){"string"==typeof t&&(e="binary"===t?new Uint8Array(16):null,t=null);var u=(t=t||{}).random||(t.rng||n)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,e){for(var i=r||0,d=0;d<16;++d)e[i+d]=u[d];return e}return function(t,e){var n=e||0,r=o;return(r[t[n+0]]+r[t[n+1]]+r[t[n+2]]+r[t[n+3]]+"-"+r[t[n+4]]+r[t[n+5]]+"-"+r[t[n+6]]+r[t[n+7]]+"-"+r[t[n+8]]+r[t[n+9]]+"-"+r[t[n+10]]+r[t[n+11]]+r[t[n+12]]+r[t[n+13]]+r[t[n+14]]+r[t[n+15]]).toLowerCase()}(u)}})); \ No newline at end of file