Skip to content

Commit

Permalink
Merge pull request #666 from hogashi/add-domain
Browse files Browse the repository at this point in the history
Add new domain
  • Loading branch information
hogashi authored May 17, 2024
2 parents a13abce + bec76bf commit 56298d0
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 25 deletions.
8 changes: 8 additions & 0 deletions __tests__/Constants.test.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -27,13 +31,17 @@ 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');
});

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');
});
Expand Down
2 changes: 1 addition & 1 deletion coverage/badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 29 additions & 9 deletions dist/css/popup.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
! tailwindcss v3.3.5 | MIT License | https://tailwindcss.com
! tailwindcss v3.4.3 | MIT License | https://tailwindcss.com
*/

/*
Expand Down Expand Up @@ -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%;
Expand All @@ -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 */
}

/*
Expand Down Expand Up @@ -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,
Expand All @@ -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 */
}

/*
Expand Down Expand Up @@ -201,6 +211,8 @@ textarea {
/* 1 */
line-height: inherit;
/* 1 */
letter-spacing: inherit;
/* 1 */
color: inherit;
/* 1 */
margin: 0;
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion dist/manifest.json
Original file line number Diff line number Diff line change
@@ -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"],
Expand All @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion src/ButtonSetter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
ORIGINAL_BUTTON_TEXT_OPTION_KEY,
OptionsBool,
type OptionsBool,
SHOW_ON_TIMELINE,
SHOW_ON_TWEETDECK_TIMELINE,
SHOW_ON_TWEET_DETAIL,
Expand Down
4 changes: 2 additions & 2 deletions src/ButtonSetterTweetDeck.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
12 changes: 10 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/extension-contexts/background.ts
Original file line number Diff line number Diff line change
@@ -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';

// バックグラウンドで実行される
Expand Down
2 changes: 1 addition & 1 deletion src/extension-contexts/options.ts
Original file line number Diff line number Diff line change
@@ -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, () => {
Expand Down
19 changes: 14 additions & 5 deletions src/extension-contexts/popup.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +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,
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,
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 56298d0

Please sign in to comment.