「Webブラウザ(Chrome)」の版間の差分

Notion-MW
 
Notion-MW
 
(同じ利用者による、間の4版が非表示)
19行目: 19行目:
こうして生成されたショートカットを見ると、(例えばWindowsなら)<code>&quot;C&#58;\Program Files\Google\Chrome\Application\chrome_proxy.exe&quot;  &#45;&#45;profile&#45;directory&#61;Default &#45;&#45;app&#45;id&#61;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</code>のようなコマンドラインが設定されているのがわかるだろう。調べた結果、この<code>&#45;&#45;app&#45;id</code>というのは、以下のようなプロセスで生成されるようである。
こうして生成されたショートカットを見ると、(例えばWindowsなら)<code>&quot;C&#58;\Program Files\Google\Chrome\Application\chrome_proxy.exe&quot;  &#45;&#45;profile&#45;directory&#61;Default &#45;&#45;app&#45;id&#61;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</code>のようなコマンドラインが設定されているのがわかるだろう。調べた結果、この<code>&#45;&#45;app&#45;id</code>というのは、以下のようなプロセスで生成されるようである。


* アプリのURLを決定する。この際、manifestが指定されていれば、そこにある<code>start_url</code>が使われるようである(たとえばTwitterのを見ると、<code>&quot;start_url&quot;&#58;&quot;https&#58;//twitter.com/?utm_source&#61;homescreen&amp;utm_medium&#61;shortcut&quot;</code>と書いてある)。また、トップページのときは末尾に<code>/</code>を付ける?(例&#58; <code>https&#58;//chat.openai.com/</code>)これらに該当しない場合は普通にそのページのURLがそのまま使われる。
# アプリのURLを決定する。この際、manifestが指定されていれば、そこにある<code>start_url</code>が使われるようである(たとえばTwitterのを見ると、<code>&quot;start_url&quot;&#58;&quot;https&#58;//twitter.com/?utm_source&#61;homescreen&amp;utm_medium&#61;shortcut&quot;</code>と書いてある)。また、トップページのときは末尾に<code>/</code>を付ける?(例&#58; <code>https&#58;//chat.openai.com/</code>)これらに該当しない場合は普通にそのページのURLがそのまま使われる。
* URLにSHA&#45;256ハッシュを2度適用し、その前半部分(16進数で32桁)をa&#45;pの16文字で表現する。
# URLにSHA&#45;256ハッシュを2度適用し、その前半部分(16進数で32桁)をa&#45;pの16文字で表現する。


この2.の部分は[https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/web_applications/web_app_helpers_unittest.cc ソースコード]に書いてある[https://play.golang.org/p/VrIq_QKFjiV playground]で試すこともできる。pythonで書くと以下のようになる(URLはコマンドライン引数として渡すことを想定)。
この2.の部分は[https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/web_applications/web_app_helpers_unittest.cc ソースコード]に書いてある[https://play.golang.org/p/VrIq_QKFjiV playground]で試すこともできる。pythonで書くと以下のようになる(URLはコマンドライン引数として渡すことを想定)。


<pre class="dummy_str_python">import hashlib
<syntaxhighlight lang="python">import hashlib


m = hashlib.sha256()
m = hashlib.sha256()
m.update(bytes(&quot;https://chat.openai.com/&quot;.encode('ascii')))
m.update(bytes("https://chat.openai.com/".encode('ascii')))
m1 = hashlib.sha256()
m1 = hashlib.sha256()
m1.update(m.digest())
m1.update(m.digest())


EXTID = ''.join([chr(int(i, base=16) + ord('a')) for i in m1.hexdigest()][:32])
EXTID = ''.join([chr(int(i, base=16) + ord('a')) for i in m1.hexdigest()][:32])
print(EXTID)</pre>
print(EXTID)</syntaxhighlight>
* 参考&#58; [https://stackoverflow.com/questions/26053434/how-is-the-chrome-extension-id-of-an-unpacked-extension-generated/26058672#26058672 How is the Chrome Extension ID of an unpacked extension generated? &#45; Stack Overflow]
* 参考&#58; [https://stackoverflow.com/questions/26053434/how-is-the-chrome-extension-id-of-an-unpacked-extension-generated/26058672#26058672 How is the Chrome Extension ID of an unpacked extension generated? &#45; Stack Overflow]