{"id":29569811,"url":"https://github.com/foxrefire/line-firefox","last_synced_at":"2025-07-19T02:07:04.866Z","repository":{"id":304891645,"uuid":"1020446310","full_name":"FoxRefire/line-firefox","owner":"FoxRefire","description":"LINE 3.7.0 Firefox用非公式ポート","archived":false,"fork":false,"pushed_at":"2025-07-15T22:22:37.000Z","size":5841,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-16T21:21:15.640Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FoxRefire.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-15T22:11:55.000Z","updated_at":"2025-07-16T16:06:27.000Z","dependencies_parsed_at":"2025-07-17T03:55:56.686Z","dependency_job_id":"d507ab1f-573c-42ba-b2c7-0e585eff14f8","html_url":"https://github.com/FoxRefire/line-firefox","commit_stats":null,"previous_names":["foxrefire/line-firefox"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/FoxRefire/line-firefox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoxRefire%2Fline-firefox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoxRefire%2Fline-firefox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoxRefire%2Fline-firefox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoxRefire%2Fline-firefox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FoxRefire","download_url":"https://codeload.github.com/FoxRefire/line-firefox/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoxRefire%2Fline-firefox/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265872671,"owners_count":23842235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-19T02:07:04.330Z","updated_at":"2025-07-19T02:07:04.854Z","avatar_url":"https://github.com/FoxRefire.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LINE Firefox用非公式ポート\n\n## パッチ手順\n### * static/js/ltsmSandbox.js\n\n```shell\njs-beautify -r ./static/js/ltsmSandbox.js\n```\n\nファイル中の全ての`window.origin`、`window.location.origin`、`location.origin`を`\"chrome-extension://ophjlpahpchlmihnnnihgmmeilfjmjjc\"`に置き換え\n\n### * manifest.json\n```diff\n    {\n    //省略\n    //省略\n    \"background\": {\n--      \"service_worker\": \"background.js\",\n++      \"scripts\": [\"background.js\"],\n        \"type\": \"module\"\n    },\n--  \"sandbox\": {\n--      \"pages\": [\n--      \"ltsmSandbox.html\",\n--      \"cropperSandbox.html\"\n--      ]\n--  },\n    //省略\n    //省略\n++  \"content_security_policy\": {\n++      \"extension_pages\": \"script-src 'self' 'wasm-unsafe-eval'; object-src 'self';\"\n++  },\n++  \"browser_specific_settings\": {\n++      \"gecko\": {\n++          \"id\": \"LINEPorted@FoxRefire\"\n++      }\n++  },\n--  \"key\": \"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuOql7UFiY9pkxo4aAmuN2HHlZhNT5ws6knRdxYhOACJcm1sBfB7GIIMuBwtpYSb3B3m7jbrKqX2iDdgYLxE9ZmFjYgrD6p4D4H9/4FCz/a7h66vp0onNu2PmbZOEnpZKeCgUGMDDcXk673R8tPfkBbmuzQ0rvpc1Z8hWgHo1jLtnjpkTlH4vzu9FGRQFsCuqUzJPjoPpa2rozvTPpmiO2qfcqH3FJoGJbKwXIPZ74JI8cY//o6xFDVhugveN1VqoGZA8PsVliAa5fgBqDohfiv36xkuD88BqynKNn00hGibuXrj4L6mnR+9I68dhwAiXY01gihtI6KhbekToLfoJmwIDAQAB\",\n    \"version\": \"3.7.0\"\n    }\n```\n\n### * background.js\n\n```shell\njs-beautify -r ./background.js\n```\n\n```diff\n--  chrome.action.onClicked.addListener((async () =\u003e {\n--  //省略\n--  //省略\n--  }));\n++  if(chrome.windows){\n++      chrome.action.onClicked.addListener(() =\u003e {\n++          chrome.windows.create({\n++              url: \"index.html\",\n++              type: \"popup\",\n++              width: 710,\n++              height: 570\n++          });\n++      });\n++  } else {\n++      chrome.action.onClicked.addListener(() =\u003e {\n++          chrome.tabs.create({url: \"index.html\"})\n++      })\n++  }\n```\n\n## Writeup\n\nまず、一般的なポート手順であるマニフェスト内のbackground.service_workerをbackground.scriptsに変更しbrowser_specific_settingsの追加を行って`moz-extension://Internal-UUID/index.html`を開いてみる。\nこのままではWebAssembly実行でCSPエラーが発生したため更にマニフェストにcontent_security_policyを追加して再実行。\n\u003cimg width=\"1522\" height=\"123\" alt=\"1\" src=\"https://github.com/user-attachments/assets/21f30da6-24ea-492f-8830-70913804e2a4\" /\u003e\n\nまだ、ltsm_not_availableというエラーが発生していたが、スタックトレースからは直接の原因箇所が明らかではなかったため、大元のエラー箇所を探ることにする\n\u003cimg width=\"1522\" height=\"302\" alt=\"2\" src=\"https://github.com/user-attachments/assets/c6cba9df-2fd8-454b-9e7e-a96b3376a1ec\" /\u003e\n\nデバッガーからltsmSandboxを呼び出している`setup()`の`catch`内にブレークポイントを設定して、監視式に`console.log(e)`と登録してみる\n\u003cimg width=\"2473\" height=\"671\" alt=\"3\" src=\"https://github.com/user-attachments/assets/b3ff9733-fa41-49ca-a858-f4c5a3d11ce9\" /\u003e\n\nコンソールにさらに上流のエラーと見られる`Error: sandbox_error`が記録された\n\u003cimg width=\"1522\" height=\"398\" alt=\"4\" src=\"https://github.com/user-attachments/assets/05a1d771-f41c-44d1-8f8d-f28c38277844\" /\u003e\n\n更に`this.sandbox`をエクスポートしてみて実際に`init()`、`sendMessage()`を実行してみると`sendMessage`内で`sandbox_error`が発生していた\n\u003cimg width=\"1522\" height=\"398\" alt=\"5\" src=\"https://github.com/user-attachments/assets/b0e33602-6512-4111-8b2a-90a29b3349f7\" /\u003e\n\nしかしスタックトレースから辿ったところこのエラーも根本原因のエラーではなく、`jp`クラス内で`r(new Op(_d.SANDBOX_ERROR))`というコードによってスローされていることが分かった。\n更に根本的な原因を探るため`jp`クラスのコンストラクタ内にブレークポイントを設定し、監視式に`console.log(t.data)`を登録\n\u003cimg width=\"2473\" height=\"1019\" alt=\"6\" src=\"https://github.com/user-attachments/assets/b039ad70-666c-4e82-8fc3-19384bc2244e\" /\u003e\n\n\n根本原因とみられるエラー`Invalid origin: moz-extension://Internal-UUID`が確認できた\n\u003cimg width=\"2473\" height=\"606\" alt=\"7\" src=\"https://github.com/user-attachments/assets/3f4d9a02-84be-4c7c-a3d9-995579799375\" /\u003e\n\n`ltsmSandbox.js`をjs-beautifyでインデントを整えてから開き、ファイル内で`Invalid origin`と検索してみる\nコードを見ると拡張機能のオリジンに応じて使用するトークンを選択しているようだ。\n`moz-extension://Internal-UUID`はトークンと対応していないため、エラーが発生していることが分かった。\n\u003cimg width=\"1882\" height=\"306\" alt=\"8\" src=\"https://github.com/user-attachments/assets/7a6569eb-bf55-445f-bc3d-c8a62a947a05\" /\u003e\n\nそこで、`ltsmSandbox.js`内の全ての現在のオリジンを取得している部分の処理を本来のオリジン`\"chrome-extension://ophjlpahpchlmihnnnihgmmeilfjmjjc\"`に上書きしてみたところ、正しく動作するようになった。\n\u003cimg width=\"1522\" height=\"1220\" alt=\"9\" src=\"https://github.com/user-attachments/assets/72480461-b2fd-452e-b5ca-4cbb03fa0764\" /\u003e\n\u003cimg width=\"1522\" height=\"1220\" alt=\"10\" src=\"https://github.com/user-attachments/assets/e7ac1dc7-30c9-4d88-822d-876e67213392\" /\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxrefire%2Fline-firefox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoxrefire%2Fline-firefox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxrefire%2Fline-firefox/lists"}