diff options
Diffstat (limited to 'ext/mixed/js')
| -rw-r--r-- | ext/mixed/js/core.js | 10 | ||||
| -rw-r--r-- | ext/mixed/js/display-history.js | 2 | ||||
| -rw-r--r-- | ext/mixed/js/frame-client.js | 2 | ||||
| -rw-r--r-- | ext/mixed/js/frame-endpoint.js | 2 | ||||
| -rw-r--r-- | ext/mixed/js/yomichan.js | 10 | 
5 files changed, 13 insertions, 13 deletions
| diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js index 7cdd62d8..9142a846 100644 --- a/ext/mixed/js/core.js +++ b/ext/mixed/js/core.js @@ -197,6 +197,16 @@ if (typeof window === 'object' && window !== null) {      window.clone = clone;  } +function generateId(length) { +    const array = new Uint8Array(length); +    crypto.getRandomValues(array); +    let id = ''; +    for (const value of array) { +        id += value.toString(16).padStart(2, '0'); +    } +    return id; +} +  /*   * Async utilities diff --git a/ext/mixed/js/display-history.js b/ext/mixed/js/display-history.js index cf2db8d5..a369e6fa 100644 --- a/ext/mixed/js/display-history.js +++ b/ext/mixed/js/display-history.js @@ -166,7 +166,7 @@ class DisplayHistory extends EventDispatcher {      }      _generateId() { -        return yomichan.generateId(16); +        return generateId(16);      }      _clear() { diff --git a/ext/mixed/js/frame-client.js b/ext/mixed/js/frame-client.js index 6ea344e2..632c50d4 100644 --- a/ext/mixed/js/frame-client.js +++ b/ext/mixed/js/frame-client.js @@ -90,7 +90,7 @@ class FrameClient {                          case 'frameEndpointReady':                              {                                  const {secret} = params; -                                const token = yomichan.generateId(16); +                                const token = generateId(16);                                  tokenMap.set(secret, token);                                  postMessage('frameEndpointConnect', {secret, token, hostFrameId});                              } diff --git a/ext/mixed/js/frame-endpoint.js b/ext/mixed/js/frame-endpoint.js index 1cd25bb5..1414442d 100644 --- a/ext/mixed/js/frame-endpoint.js +++ b/ext/mixed/js/frame-endpoint.js @@ -21,7 +21,7 @@  class FrameEndpoint {      constructor() { -        this._secret = yomichan.generateId(16); +        this._secret = generateId(16);          this._token = null;          this._eventListeners = new EventListenerCollection();          this._eventListenersSetup = false; diff --git a/ext/mixed/js/yomichan.js b/ext/mixed/js/yomichan.js index 2de82274..9e049d41 100644 --- a/ext/mixed/js/yomichan.js +++ b/ext/mixed/js/yomichan.js @@ -84,16 +84,6 @@ const yomichan = (() => {              this.sendMessage({action: 'yomichanReady'});          } -        generateId(length) { -            const array = new Uint8Array(length); -            crypto.getRandomValues(array); -            let id = ''; -            for (const value of array) { -                id += value.toString(16).padStart(2, '0'); -            } -            return id; -        } -          isExtensionUrl(url) {              try {                  return url.startsWith(chrome.runtime.getURL('/')); |