From 5942d1f274da6715a43b14ca287d04415a277866 Mon Sep 17 00:00:00 2001 From: 53JIlLenWe11 Date: Sat, 12 Oct 2019 21:05:38 +0900 Subject: [PATCH 1/7] =?UTF-8?q?eslint=E3=81=AE=E8=A8=AD=E5=AE=9A=E3=81=A7w?= =?UTF-8?q?ebextentions=E3=81=AE=E3=82=B3=E3=83=BC=E3=83=89=E3=81=B8?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C=E3=81=95=E3=81=9B=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc | 20 ++++++++++++++++++++ .eslintrc.json | 15 --------------- .prettierrc | 3 +-- 3 files changed, 21 insertions(+), 17 deletions(-) create mode 100644 .eslintrc delete mode 100644 .eslintrc.json diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..69e3eea --- /dev/null +++ b/.eslintrc @@ -0,0 +1,20 @@ +{ + "env": { + "browser": true, + "jquery": true, + "es6": true, + "webextensions": true + }, + "parserOptions": { + "sourceType": "module", // ES Moduleを有効にする + "ecmaVersion": 2018 // async functionに対してparse error吐くので最新の記載に対応 + }, + "extends": [ + "eslint:recommended", // ESLintが推奨するチェック項目でまとめてチェックする + "plugin:prettier/recommended" // ESLintでPrettierを実施し、ESLintと衝突ルールは回避する設定を有効にする + // デフォルトで.prettierrcの設定を読み込む + ], + "rules": { + "no-console": 1 // consoleを警告する 2はエラーとする + } +} \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index d128aa7..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "env": { - "browser": true, - "jquery": true, - "es6": true - }, - "extends": [ - "eslint:recommended" // おすすめ設定を追加 - ], - "parserOptions": { - "sourceType": "module", - "ecmaVersion": 2017 // async functionに対してparse error吐くのでその対策 - }, - "globals": {} -} \ No newline at end of file diff --git a/.prettierrc b/.prettierrc index 930bbc5..9a21fcf 100644 --- a/.prettierrc +++ b/.prettierrc @@ -4,6 +4,5 @@ "singleQuote": true, "semi": true, "printWidth": 120, - "trailingComma": "all", - "trailingCommaPHP":"php5" + "trailingComma": "es5" } \ No newline at end of file From 0443cfef412a6b141b3a88e7ffb35472f3b1dceb Mon Sep 17 00:00:00 2001 From: 53JIlLenWe11 Date: Sat, 12 Oct 2019 21:07:55 +0900 Subject: [PATCH 2/7] =?UTF-8?q?=E3=81=A8=E3=82=8A=E3=81=82=E3=81=88?= =?UTF-8?q?=E3=81=9A=E3=80=81eslint+prettier=E3=81=A7=E6=95=B4=E5=BD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- background.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/background.js b/background.js index 749092a..dec959b 100644 --- a/background.js +++ b/background.js @@ -32,20 +32,22 @@ async function set_eappid() { await connecter.get_method(); const text = await connecter.get_text(); - const patterns = [ - /eappid\u0022:\u0022(.+?)\u0022,\u0022/, - /eappid\\u0022:\\u0022(.+?)\\u0022,\\u0022/, - ]; + const patterns = [/eappid\u0022:\u0022(.+?)\u0022,\u0022/, /eappid\\u0022:\\u0022(.+?)\\u0022,\\u0022/]; let page_eappid = null; - for ( let pattern of patterns ) { + for (let pattern of patterns) { page_eappid = text.match(pattern); - if ( page_eappid !== null ) { + if (page_eappid !== null) { break; } } console.log('取得したeappid', page_eappid); if (page_eappid !== null) { - chrome.storage.local.set({ eappid: page_eappid[1] }, () => {}); + chrome.storage.local.set( + { + eappid: page_eappid[1], + }, + () => {} + ); return page_eappid[1]; } } catch (error) { @@ -61,7 +63,12 @@ async function get_eappid() { } function clear_eappid() { - chrome.storage.local.set({ eappid: null }, () => {}); + chrome.storage.local.set( + { + eappid: null, + }, + () => {} + ); } async function is_login() { @@ -78,8 +85,8 @@ async function is_login() { // - ID新規作成リンク: https://account.edit.yahoo.co.jp/registration?... // - 登録情報: https://login.yahoo.co.jp/config/login?... const a_in_login_box = html.querySelectorAll('#Login a'); - for ( a of a_in_login_box ) { - if ( a.href.match(/^https:\/\/accounts.yahoo.co.jp\/profile\?/) ) { + for (a of a_in_login_box) { + if (a.href.match(/^https:\/\/accounts.yahoo.co.jp\/profile\?/)) { return true; } } @@ -99,7 +106,7 @@ async function get_mail_count_core(eappid) { async function get_mail_count() { try { const eappid = await get_eappid(); - if ( eappid ) { + if (eappid) { try { return await get_mail_count_core(eappid); } catch (error) { @@ -123,7 +130,7 @@ async function get_mail_count2() { return 'login'; } const eappid = await set_eappid(); - if ( ! eappid ) { + if (!eappid) { return 0; } return await get_mail_count_core(eappid); From 730c2590c80ea9e31fc338937179143ea943a3f6 Mon Sep 17 00:00:00 2001 From: 53JIlLenWe11 Date: Sat, 12 Oct 2019 21:50:10 +0900 Subject: [PATCH 3/7] =?UTF-8?q?=E5=A4=89=E6=95=B0=E5=AE=A3=E8=A8=80?= =?UTF-8?q?=E3=81=AE=E8=BF=BD=E5=8A=A0=E3=81=A8=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- background.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/background.js b/background.js index dec959b..8b24cb5 100644 --- a/background.js +++ b/background.js @@ -34,7 +34,7 @@ async function set_eappid() { const patterns = [/eappid\u0022:\u0022(.+?)\u0022,\u0022/, /eappid\\u0022:\\u0022(.+?)\\u0022,\\u0022/]; let page_eappid = null; - for (let pattern of patterns) { + for (const pattern of patterns) { page_eappid = text.match(pattern); if (page_eappid !== null) { break; @@ -85,7 +85,7 @@ async function is_login() { // - ID新規作成リンク: https://account.edit.yahoo.co.jp/registration?... // - 登録情報: https://login.yahoo.co.jp/config/login?... const a_in_login_box = html.querySelectorAll('#Login a'); - for (a of a_in_login_box) { + for (const a of a_in_login_box) { if (a.href.match(/^https:\/\/accounts.yahoo.co.jp\/profile\?/)) { return true; } From ce9ea9be94daf1d63e084ae1dd0186787c7dabed Mon Sep 17 00:00:00 2001 From: 53JIlLenWe11 Date: Sat, 12 Oct 2019 21:55:57 +0900 Subject: [PATCH 4/7] =?UTF-8?q?=E5=A4=B1=E6=95=97=E6=99=82=E3=81=AB?= =?UTF-8?q?=E4=BB=B6=E6=95=B0=E3=82=92-=E3=81=A7=E5=87=BA=E3=81=99?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- background.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/background.js b/background.js index 8b24cb5..f5b5d6e 100644 --- a/background.js +++ b/background.js @@ -117,7 +117,7 @@ async function get_mail_count() { } } catch (error) { console.log(error); - return 0; + return '-'; } } @@ -131,12 +131,12 @@ async function get_mail_count2() { } const eappid = await set_eappid(); if (!eappid) { - return 0; + return '-'; } return await get_mail_count_core(eappid); } catch (error) { console.log(error); - return 0; + return '-'; } } From 0639eedb0da2acbdffd3f32f3eba0c8b569d388f Mon Sep 17 00:00:00 2001 From: 53JIlLenWe11 Date: Sat, 12 Oct 2019 22:04:52 +0900 Subject: [PATCH 5/7] =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E6=99=82?= =?UTF-8?q?=E3=81=ABeappid=E3=82=92clear=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- background.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/background.js b/background.js index f5b5d6e..cebc4ce 100644 --- a/background.js +++ b/background.js @@ -52,9 +52,9 @@ async function set_eappid() { } } catch (error) { console.log(error); + clear_eappid(); + return null; } - clear_eappid(); - return null; } async function get_eappid() { From 94c9ccc0699f0366ae30d019b14d89097aaca470 Mon Sep 17 00:00:00 2001 From: 53JIlLenWe11 Date: Sat, 12 Oct 2019 22:23:33 +0900 Subject: [PATCH 6/7] =?UTF-8?q?=E9=96=A2=E6=95=B0=E5=90=8D=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- background.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/background.js b/background.js index cebc4ce..a27acb3 100644 --- a/background.js +++ b/background.js @@ -13,7 +13,7 @@ setInterval(function() { function view_new_mail_count() { (async () => { - let mail_count = await get_mail_count(); + let mail_count = await mail_count_fetch_process(); console.log('mail_count', mail_count); if (mail_count == 0) { @@ -93,7 +93,7 @@ async function is_login() { return false; } -async function get_mail_count_core(eappid) { +async function get_mail_count(eappid) { const connecter = new api_connecter(new_mail_count_url + eappid); await connecter.get_method(); const json = await connecter.get_json(); @@ -103,17 +103,17 @@ async function get_mail_count_core(eappid) { // すでに取得済みの eappid でメール件数の取得を試みる。 // ダメなら get_mail_count2 へ。 -async function get_mail_count() { +async function mail_count_fetch_process() { try { const eappid = await get_eappid(); if (eappid) { try { - return await get_mail_count_core(eappid); + return await get_mail_count(eappid); } catch (error) { - return await get_mail_count2(); + return await eaapid_reacquisition_after_get_mail_count(); } } else { - return await get_mail_count2(); + return await eaapid_reacquisition_after_get_mail_count(); } } catch (error) { console.log(error); @@ -122,7 +122,7 @@ async function get_mail_count() { } // ログイン判定、eaippidの取得をした後にメール件数の取得を試みる。 -async function get_mail_count2() { +async function eaapid_reacquisition_after_get_mail_count() { try { if (!(await is_login())) { // ログインしていない @@ -133,7 +133,7 @@ async function get_mail_count2() { if (!eappid) { return '-'; } - return await get_mail_count_core(eappid); + return await get_mail_count(eappid); } catch (error) { console.log(error); return '-'; From a2b79ed494eda6a5b9ea023bb75ecc4f5e1d6bc8 Mon Sep 17 00:00:00 2001 From: 53JIlLenWe11 Date: Sat, 12 Oct 2019 22:52:20 +0900 Subject: [PATCH 7/7] ver 0.10 update --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 548e5a9..bc5d152 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "ヤフーメール通知", - "version": "0.9", + "version": "0.10", "manifest_version": 2, "description": "ヤフーメール通知拡張 30秒に一度自動で確認 ログインしておく必要があります。", "permissions": [