Skip to content

Commit

Permalink
delete unused vars
Browse files Browse the repository at this point in the history
  • Loading branch information
hogashi committed Nov 28, 2023
1 parent d531dd0 commit 27017a9
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 53 deletions.
17 changes: 0 additions & 17 deletions __tests__/Constants.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
GET_LOCAL_STORAGE,
HOST_PBS_TWIMG_COM,
HOST_PRO_TWITTER_COM,
HOST_TWEETDECK_TWITTER_COM,
HOST_TWITTER_COM,
Expand All @@ -11,9 +10,7 @@ import {
SHOW_ON_TWEETDECK_TIMELINE,
SHOW_ON_TWEETDECK_TWEET_DETAIL,
SHOW_ON_TWEET_DETAIL,
STRIP_IMAGE_SUFFIX,
initialOptionsBool,
isImageTab,
isNativeChromeExtension,
isReactView,
isTweetdeck,
Expand All @@ -39,18 +36,12 @@ describe('定数', () => {
expect(SHOW_ON_TWEETDECK_TWEET_DETAIL).toBe('SHOW_ON_TWEETDECK_TWEET_DETAIL');
});

it('画像ページ', () => {
expect(HOST_PBS_TWIMG_COM).toBe('pbs.twimg.com');
expect(STRIP_IMAGE_SUFFIX).toBe('STRIP_IMAGE_SUFFIX');
});

it('初期設定', () => {
expect(initialOptionsBool).toStrictEqual({
SHOW_ON_TIMELINE: true,
SHOW_ON_TWEET_DETAIL: true,
SHOW_ON_TWEETDECK_TIMELINE: true,
SHOW_ON_TWEETDECK_TWEET_DETAIL: true,
STRIP_IMAGE_SUFFIX: true,
});
});

Expand All @@ -60,17 +51,13 @@ describe('定数', () => {
SHOW_ON_TWEET_DETAIL,
SHOW_ON_TWEETDECK_TIMELINE,
SHOW_ON_TWEETDECK_TWEET_DETAIL,
STRIP_IMAGE_SUFFIX,
]);

expect(OPTIONS_TEXT).toStrictEqual({
SHOW_ON_TIMELINE: 'タイムライン',
SHOW_ON_TWEET_DETAIL: '(旧表示で)ツイート詳細',
// TweetDeck
SHOW_ON_TWEETDECK_TIMELINE: 'タイムライン',
SHOW_ON_TWEETDECK_TWEET_DETAIL: '(旧表示で)ツイート詳細',
// 画像ページ
STRIP_IMAGE_SUFFIX: '[Ctrl]+[s]で拡張子を校正',
});
});

Expand All @@ -87,27 +74,23 @@ describe('定数', () => {
window.location = new URL('https://twitter.com');
expect(isTwitter()).toBeTruthy();
expect(isTweetdeck()).toBeFalsy();
expect(isImageTab()).toBeFalsy();
});
describe('TweetDeck', () => {
it('tweetdeck.twitter.com', () => {
window.location = new URL('https://tweetdeck.twitter.com');
expect(isTwitter()).toBeFalsy();
expect(isTweetdeck()).toBeTruthy();
expect(isImageTab()).toBeFalsy();
});
it('pro.twitter.com', () => {
window.location = new URL('https://pro.twitter.com');
expect(isTwitter()).toBeFalsy();
expect(isTweetdeck()).toBeTruthy();
expect(isImageTab()).toBeFalsy();
});
});
it('画像ページ', () => {
window.location = new URL('https://pbs.twimg.com');
expect(isTwitter()).toBeFalsy();
expect(isTweetdeck()).toBeFalsy();
expect(isImageTab()).toBeTruthy();
});
});

Expand Down
2 changes: 1 addition & 1 deletion __tests__/__snapshots__/popup.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`Popup render 1`] = `
className="p-3 flex flex-col justify-center items-center"
style={
{
"minWidth": "230px",
"minWidth": "260px",
}
}
>
Expand Down
12 changes: 0 additions & 12 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ export const HOST_TWEETDECK_TWITTER_COM = 'tweetdeck.twitter.com';
export const HOST_PRO_TWITTER_COM = 'pro.twitter.com';
export const SHOW_ON_TWEETDECK_TIMELINE = 'SHOW_ON_TWEETDECK_TIMELINE';
export const SHOW_ON_TWEETDECK_TWEET_DETAIL = 'SHOW_ON_TWEETDECK_TWEET_DETAIL';
// 画像ページ
export const HOST_PBS_TWIMG_COM = 'pbs.twimg.com';
export const STRIP_IMAGE_SUFFIX = 'STRIP_IMAGE_SUFFIX';

/**
* 設定項目
Expand All @@ -26,8 +23,6 @@ export interface OptionsBool {
// TweetDeck
SHOW_ON_TWEETDECK_TIMELINE: boolean;
SHOW_ON_TWEETDECK_TWEET_DETAIL: boolean;
// 画像ページ
STRIP_IMAGE_SUFFIX: boolean;
}

export const initialOptionsBool: OptionsBool = {
Expand All @@ -37,16 +32,13 @@ export const initialOptionsBool: OptionsBool = {
// TweetDeck
SHOW_ON_TWEETDECK_TIMELINE: true,
SHOW_ON_TWEETDECK_TWEET_DETAIL: true,
// 画像ページ
STRIP_IMAGE_SUFFIX: true,
};

export const OPTION_KEYS = [
SHOW_ON_TIMELINE,
SHOW_ON_TWEET_DETAIL,
SHOW_ON_TWEETDECK_TIMELINE,
SHOW_ON_TWEETDECK_TWEET_DETAIL,
STRIP_IMAGE_SUFFIX,
] as const;
export const OPTIONS_TEXT: { [key in keyof OptionsBool]: string } = {
// 公式Web
Expand All @@ -55,8 +47,6 @@ export const OPTIONS_TEXT: { [key in keyof OptionsBool]: string } = {
// TweetDeck
SHOW_ON_TWEETDECK_TIMELINE: 'タイムライン',
SHOW_ON_TWEETDECK_TWEET_DETAIL: '(旧表示で)ツイート詳細',
// 画像ページ
STRIP_IMAGE_SUFFIX: '[Ctrl]+[s]で拡張子を校正',
};

/** 公式Webかどうか */
Expand All @@ -65,8 +55,6 @@ export const isTwitter = (): boolean =>
/** Tweetdeckかどうか */
export const isTweetdeck = (): boolean =>
window.location.hostname === HOST_TWEETDECK_TWITTER_COM || window.location.hostname === HOST_PRO_TWITTER_COM;
/** 画像ページかどうか */
export const isImageTab = (): boolean => window.location.hostname === HOST_PBS_TWIMG_COM;

/** Reactビューかどうか */
export const isReactView = (): boolean => !!document.getElementById('react-root');
Expand Down
9 changes: 2 additions & 7 deletions src/extension-contexts/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useCallback, useState } from 'react';
import ReactDOM from 'react-dom';
import {
HOST_MOBILE_TWITTER_COM,
HOST_PBS_TWIMG_COM,
HOST_TWEETDECK_TWITTER_COM,
HOST_TWITTER_COM,
OPTIONS_TEXT,
Expand Down Expand Up @@ -46,11 +45,7 @@ export const Popup = (props: Props): JSX.Element => {
return;
}
const tabUrl = new URL(tab.url).hostname;
if (
![HOST_TWITTER_COM, HOST_MOBILE_TWITTER_COM, HOST_TWEETDECK_TWITTER_COM, HOST_PBS_TWIMG_COM].some(
(url) => url === tabUrl,
)
) {
if (![HOST_TWITTER_COM, HOST_MOBILE_TWITTER_COM, HOST_TWEETDECK_TWITTER_COM].some((url) => url === tabUrl)) {
// 送り先タブが拡張機能が動作する対象ではないならメッセージを送らない
return;
}
Expand Down Expand Up @@ -91,7 +86,7 @@ export const Popup = (props: Props): JSX.Element => {
<div
className="p-3 flex flex-col justify-center items-center"
style={{
minWidth: '230px',
minWidth: '260px',
}}
>
<h1 className="text-xl font-bold leading-7 text-gray-900 self-center sm:truncate sm:text-3xl sm:tracking-tight">
Expand Down
16 changes: 0 additions & 16 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
GET_LOCAL_STORAGE,
OPTION_UPDATED,
OptionsBool,
STRIP_IMAGE_SUFFIX,
initialOptionsBool,
isNativeChromeExtension,
isReactView,
Expand Down Expand Up @@ -277,18 +276,3 @@ export const setOriginalButton = (options: OptionsBool): void => {
});
}
};

/**
* @deprecated
* twitterの画像を表示したときのC-sを拡張
* 画像のファイル名を「~.jpg-orig」「~.png-orig」ではなく「~-orig.jpg」「~-orig.png」にする
*/
export const fixFileNameOnSaveCommand = (options: OptionsBool): void => {
// キーを押したとき
document.addEventListener('keydown', (e) => {
// 設定が有効なら
if (options[STRIP_IMAGE_SUFFIX]) {
downloadImage(e);
}
});
};

0 comments on commit 27017a9

Please sign in to comment.