From 144afcbee3a1d2f96ed7d4158a92b2dd3644964b Mon Sep 17 00:00:00 2001 From: hogashi Date: Fri, 17 May 2024 21:51:33 +0900 Subject: [PATCH 1/4] add new domains --- dist/css/popup.css | 38 ++++++++++++++++++++++++-------- dist/manifest.json | 3 +++ src/constants.ts | 12 ++++++++-- src/extension-contexts/popup.tsx | 15 ++++++++++--- 4 files changed, 54 insertions(+), 14 deletions(-) diff --git a/dist/css/popup.css b/dist/css/popup.css index 2e4eb57b..c34de971 100644 --- a/dist/css/popup.css +++ b/dist/css/popup.css @@ -1,5 +1,5 @@ /* -! tailwindcss v3.3.5 | MIT License | https://tailwindcss.com +! tailwindcss v3.4.3 | MIT License | https://tailwindcss.com */ /* @@ -32,9 +32,11 @@ 4. Use the user's configured `sans` font-family by default. 5. Use the user's configured `sans` font-feature-settings by default. 6. Use the user's configured `sans` font-variation-settings by default. +7. Disable tap highlights on iOS */ -html { +html, +:host { line-height: 1.5; /* 1 */ -webkit-text-size-adjust: 100%; @@ -44,12 +46,14 @@ html { -o-tab-size: 4; tab-size: 4; /* 3 */ - font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; + font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; /* 4 */ font-feature-settings: normal; /* 5 */ font-variation-settings: normal; /* 6 */ + -webkit-tap-highlight-color: transparent; + /* 7 */ } /* @@ -121,8 +125,10 @@ strong { } /* -1. Use the user's configured `mono` font family by default. -2. Correct the odd `em` font sizing in all browsers. +1. Use the user's configured `mono` font-family by default. +2. Use the user's configured `mono` font-feature-settings by default. +3. Use the user's configured `mono` font-variation-settings by default. +4. Correct the odd `em` font sizing in all browsers. */ code, @@ -131,8 +137,12 @@ samp, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; /* 1 */ - font-size: 1em; + font-feature-settings: normal; /* 2 */ + font-variation-settings: normal; + /* 3 */ + font-size: 1em; + /* 4 */ } /* @@ -201,6 +211,8 @@ textarea { /* 1 */ line-height: inherit; /* 1 */ + letter-spacing: inherit; + /* 1 */ color: inherit; /* 1 */ margin: 0; @@ -224,9 +236,9 @@ select { */ button, -[type='button'], -[type='reset'], -[type='submit'] { +input:where([type='button']), +input:where([type='reset']), +input:where([type='submit']) { -webkit-appearance: button; /* 1 */ background-color: transparent; @@ -482,6 +494,10 @@ video { --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; + --tw-contain-size: ; + --tw-contain-layout: ; + --tw-contain-paint: ; + --tw-contain-style: ; } ::backdrop { @@ -532,6 +548,10 @@ video { --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; + --tw-contain-size: ; + --tw-contain-layout: ; + --tw-contain-paint: ; + --tw-contain-style: ; } .relative { diff --git a/dist/manifest.json b/dist/manifest.json index 1d0f104e..d4c9a8fc 100644 --- a/dist/manifest.json +++ b/dist/manifest.json @@ -14,9 +14,12 @@ { "matches": [ "https://twitter.com/*", + "https://x.com/*", "https://mobile.twitter.com/*", + "https://mobile.x.com/*", "https://tweetdeck.twitter.com/*", "https://pro.twitter.com/*", + "https://pro.x.com/*", "https://pbs.twimg.com/*" ], "js": ["js/main.bundle.js"] diff --git a/src/constants.ts b/src/constants.ts index 0c3c6cd0..0d462d3e 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -9,11 +9,14 @@ export const GET_LOCAL_STORAGE = 'GET_LOCAL_STORAGE'; // 公式Web export const HOST_TWITTER_COM = 'twitter.com'; export const HOST_MOBILE_TWITTER_COM = 'mobile.twitter.com'; +export const HOST_X_COM = 'x.com'; +export const HOST_MOBILE_X_COM = 'mobile.x.com'; export const SHOW_ON_TIMELINE = 'SHOW_ON_TIMELINE'; export const SHOW_ON_TWEET_DETAIL = 'SHOW_ON_TWEET_DETAIL'; // TweetDeck export const HOST_TWEETDECK_TWITTER_COM = 'tweetdeck.twitter.com'; export const HOST_PRO_TWITTER_COM = 'pro.twitter.com'; +export const HOST_PRO_X_COM = 'pro.x.com'; export const SHOW_ON_TWEETDECK_TIMELINE = 'SHOW_ON_TWEETDECK_TIMELINE'; export const SHOW_ON_TWEETDECK_TWEET_DETAIL = 'SHOW_ON_TWEETDECK_TWEET_DETAIL'; @@ -64,10 +67,15 @@ export const OPTIONS_TEXT: { [key in keyof OptionsBool]: string } = { /** 公式Webかどうか */ export const isTwitter = (): boolean => - window.location.hostname === HOST_TWITTER_COM || window.location.hostname === HOST_MOBILE_TWITTER_COM; + window.location.hostname === HOST_TWITTER_COM || + window.location.hostname === HOST_MOBILE_TWITTER_COM || + window.location.hostname === HOST_X_COM || + window.location.hostname === HOST_MOBILE_X_COM; /** Tweetdeckかどうか */ export const isTweetdeck = (): boolean => - window.location.hostname === HOST_TWEETDECK_TWITTER_COM || window.location.hostname === HOST_PRO_TWITTER_COM; + window.location.hostname === HOST_TWEETDECK_TWITTER_COM || + window.location.hostname === HOST_PRO_TWITTER_COM || + window.location.hostname === HOST_PRO_X_COM; /** Reactビューかどうか */ export const isReactView = (): boolean => !!document.getElementById('react-root'); diff --git a/src/extension-contexts/popup.tsx b/src/extension-contexts/popup.tsx index 929d5d52..2b41ef01 100644 --- a/src/extension-contexts/popup.tsx +++ b/src/extension-contexts/popup.tsx @@ -5,6 +5,9 @@ import { HOST_PRO_TWITTER_COM, HOST_TWEETDECK_TWITTER_COM, HOST_TWITTER_COM, + HOST_X_COM, + HOST_MOBILE_X_COM, + HOST_PRO_X_COM, OPTIONS_TEXT, OPTION_KEYS, OPTION_UPDATED, @@ -55,9 +58,15 @@ export const Popup = (props: Props): JSX.Element => { } const tabUrl = new URL(tab.url).hostname; if ( - ![HOST_TWITTER_COM, HOST_MOBILE_TWITTER_COM, HOST_TWEETDECK_TWITTER_COM, HOST_PRO_TWITTER_COM].some( - (url) => url === tabUrl, - ) + ![ + HOST_TWITTER_COM, + HOST_MOBILE_TWITTER_COM, + HOST_TWEETDECK_TWITTER_COM, + HOST_PRO_TWITTER_COM, + HOST_X_COM, + HOST_MOBILE_X_COM, + HOST_PRO_X_COM, + ].some((url) => url === tabUrl) ) { // 送り先タブが拡張機能が動作する対象ではないならメッセージを送らない return; From 752493751e998071f3d6dd48f6b1062161b4aa3d Mon Sep 17 00:00:00 2001 From: hogashi Date: Fri, 17 May 2024 21:52:05 +0900 Subject: [PATCH 2/4] yarn test --- coverage/badge.svg | 2 +- src/ButtonSetter.ts | 2 +- src/ButtonSetterTweetDeck.ts | 4 ++-- src/extension-contexts/background.ts | 2 +- src/extension-contexts/options.ts | 2 +- src/extension-contexts/popup.tsx | 8 ++++---- src/utils.ts | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/coverage/badge.svg b/coverage/badge.svg index 3f0bf66d..20a53520 100644 --- a/coverage/badge.svg +++ b/coverage/badge.svg @@ -1 +1 @@ -Coverage: 83.68%Coverage83.68% \ No newline at end of file +Coverage: 84.13%Coverage84.13% \ No newline at end of file diff --git a/src/ButtonSetter.ts b/src/ButtonSetter.ts index bb7844c7..4e6766de 100644 --- a/src/ButtonSetter.ts +++ b/src/ButtonSetter.ts @@ -1,6 +1,6 @@ import { ORIGINAL_BUTTON_TEXT_OPTION_KEY, - OptionsBool, + type OptionsBool, SHOW_ON_TIMELINE, SHOW_ON_TWEETDECK_TIMELINE, SHOW_ON_TWEET_DETAIL, diff --git a/src/ButtonSetterTweetDeck.ts b/src/ButtonSetterTweetDeck.ts index 2d834bf9..c7f4ef6d 100644 --- a/src/ButtonSetterTweetDeck.ts +++ b/src/ButtonSetterTweetDeck.ts @@ -1,7 +1,7 @@ -import { ButtonSetterType } from './ButtonSetter'; +import type { ButtonSetterType } from './ButtonSetter'; import { ORIGINAL_BUTTON_TEXT_OPTION_KEY, - OptionsBool, + type OptionsBool, SHOW_ON_TWEETDECK_TIMELINE, SHOW_ON_TWEETDECK_TWEET_DETAIL, } from './constants'; diff --git a/src/extension-contexts/background.ts b/src/extension-contexts/background.ts index 8b79d2a3..a9f6767c 100644 --- a/src/extension-contexts/background.ts +++ b/src/extension-contexts/background.ts @@ -1,5 +1,5 @@ import { GET_LOCAL_STORAGE } from '../constants'; -import { MessageRequest, MessageResponseBool } from '../utils'; +import type { MessageRequest, MessageResponseBool } from '../utils'; import { getOptions } from './options'; // バックグラウンドで実行される diff --git a/src/extension-contexts/options.ts b/src/extension-contexts/options.ts index 87d38d8d..3886cd8a 100644 --- a/src/extension-contexts/options.ts +++ b/src/extension-contexts/options.ts @@ -1,4 +1,4 @@ -import { OPTION_KEYS, OptionsBool, initialOptionsBool } from '../constants'; +import { OPTION_KEYS, type OptionsBool, initialOptionsBool } from '../constants'; export const setOptions = (options: OptionsBool, callback?: () => void): void => { chrome.storage.sync.set(options, () => { diff --git a/src/extension-contexts/popup.tsx b/src/extension-contexts/popup.tsx index 2b41ef01..74b910eb 100644 --- a/src/extension-contexts/popup.tsx +++ b/src/extension-contexts/popup.tsx @@ -1,18 +1,18 @@ -import React, { ChangeEvent, useCallback, useState } from 'react'; +import React, { type ChangeEvent, useCallback, useState } from 'react'; import ReactDOM from 'react-dom'; import { HOST_MOBILE_TWITTER_COM, + HOST_MOBILE_X_COM, HOST_PRO_TWITTER_COM, + HOST_PRO_X_COM, HOST_TWEETDECK_TWITTER_COM, HOST_TWITTER_COM, HOST_X_COM, - HOST_MOBILE_X_COM, - HOST_PRO_X_COM, OPTIONS_TEXT, OPTION_KEYS, OPTION_UPDATED, ORIGINAL_BUTTON_TEXT_OPTION_KEY, - OptionsBool, + type OptionsBool, SHOW_ON_TIMELINE, SHOW_ON_TWEETDECK_TIMELINE, SHOW_ON_TWEETDECK_TWEET_DETAIL, diff --git a/src/utils.ts b/src/utils.ts index eb8ad0fc..62d08af6 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,9 +1,9 @@ -import { ButtonSetter, ButtonSetterType } from './ButtonSetter'; +import { ButtonSetter, type ButtonSetterType } from './ButtonSetter'; import { ButtonSetterTweetDeck } from './ButtonSetterTweetDeck'; import { GET_LOCAL_STORAGE, OPTION_UPDATED, - OptionsBool, + type OptionsBool, initialOptionsBool, isNativeChromeExtension, isReactView, From 8a8d8658eb206662a810d1498f1b382501057561 Mon Sep 17 00:00:00 2001 From: hogashi Date: Fri, 17 May 2024 21:55:07 +0900 Subject: [PATCH 3/4] add tests --- __tests__/Constants.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/__tests__/Constants.test.js b/__tests__/Constants.test.js index b5124e81..4258d113 100644 --- a/__tests__/Constants.test.js +++ b/__tests__/Constants.test.js @@ -1,8 +1,12 @@ import { GET_LOCAL_STORAGE, + HOST_MOBILE_TWITTER_COM, + HOST_MOBILE_X_COM, HOST_PRO_TWITTER_COM, + HOST_PRO_X_COM, HOST_TWEETDECK_TWITTER_COM, HOST_TWITTER_COM, + HOST_X_COM, INITIAL_ORIGINAL_BUTTON_TEXT, OPTIONS_TEXT, OPTION_KEYS, @@ -27,6 +31,9 @@ describe('定数', () => { it('公式Web', () => { expect(HOST_TWITTER_COM).toBe('twitter.com'); + expect(HOST_MOBILE_TWITTER_COM).toBe('mobile.twitter.com'); + expect(HOST_X_COM).toBe('x.com'); + expect(HOST_MOBILE_X_COM).toBe('mobile.x.com'); expect(SHOW_ON_TIMELINE).toBe('SHOW_ON_TIMELINE'); expect(SHOW_ON_TWEET_DETAIL).toBe('SHOW_ON_TWEET_DETAIL'); }); @@ -34,6 +41,7 @@ describe('定数', () => { it('TweetDeck', () => { expect(HOST_TWEETDECK_TWITTER_COM).toBe('tweetdeck.twitter.com'); expect(HOST_PRO_TWITTER_COM).toBe('pro.twitter.com'); + expect(HOST_PRO_X_COM).toBe('pro.x.com'); expect(SHOW_ON_TWEETDECK_TIMELINE).toBe('SHOW_ON_TWEETDECK_TIMELINE'); expect(SHOW_ON_TWEETDECK_TWEET_DETAIL).toBe('SHOW_ON_TWEETDECK_TWEET_DETAIL'); }); From bec76bf6ab437ce2cfd6092a58b886e5a9ba6459 Mon Sep 17 00:00:00 2001 From: hogashi Date: Fri, 17 May 2024 21:56:04 +0900 Subject: [PATCH 4/4] bump version --- dist/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/manifest.json b/dist/manifest.json index d4c9a8fc..accd6915 100644 --- a/dist/manifest.json +++ b/dist/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "twitter画像原寸ボタン", - "version": "6.0.0", + "version": "7.0.0", "description": "twitterの画像ツイートにボタンを追加する拡張機能。追加されたボタンを押すとツイートの画像を原寸で新しいタブに表示する。連絡先: @hogextend", "author": "hogashi", "permissions": ["tabs", "storage"],