Skip to content

Commit

Permalink
Merge pull request #590 from hogashi/protwittercom
Browse files Browse the repository at this point in the history
add new tweetdeck domain
  • Loading branch information
hogashi authored Nov 28, 2023
2 parents 4a3689b + de47a71 commit 8cd4a91
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 15 deletions.
20 changes: 15 additions & 5 deletions __tests__/Constants.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
GET_LOCAL_STORAGE,
HOST_PBS_TWIMG_COM,
HOST_PRO_TWITTER_COM,
HOST_TWEETDECK_TWITTER_COM,
HOST_TWITTER_COM,
OPTIONS_TEXT,
Expand Down Expand Up @@ -35,6 +36,7 @@ describe('定数', () => {

it('TweetDeck', () => {
expect(HOST_TWEETDECK_TWITTER_COM).toBe('tweetdeck.twitter.com');
expect(HOST_PRO_TWITTER_COM).toBe('pro.twitter.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 Expand Up @@ -96,11 +98,19 @@ describe('定数', () => {
expect(isTweetdeck()).toBeFalsy();
expect(isImageTab()).toBeFalsy();
});
it('TweetDeck', () => {
window.location = new URL('https://tweetdeck.twitter.com');
expect(isTwitter()).toBeFalsy();
expect(isTweetdeck()).toBeTruthy();
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');
Expand Down
27 changes: 20 additions & 7 deletions __tests__/Utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,15 @@ describe('Utils', () => {
window.location = originalLocation;
});

it('古いTweetDeckではButtonSetterTweetDeck', () => {
window.location = new URL('https://tweetdeck.twitter.com');
expect(getButtonSetter()).toBeInstanceOf(ButtonSetterTweetDeck);
describe('古いTweetDeckではButtonSetterTweetDeck', () => {
it('tweetdeck.twitter.com', () => {
window.location = new URL('https://tweetdeck.twitter.com');
expect(getButtonSetter()).toBeInstanceOf(ButtonSetterTweetDeck);
});
it('pro.twitter.com', () => {
window.location = new URL('https://pro.twitter.com');
expect(getButtonSetter()).toBeInstanceOf(ButtonSetterTweetDeck);
});
});
it('公式WebではButtonSetter', () => {
window.location = new URL('https://twitter.com');
Expand All @@ -429,10 +435,17 @@ describe('Utils', () => {
window.location = new URL('https://mobile.twitter.com');
expect(getButtonSetter()).toBeInstanceOf(ButtonSetter);
});
it('新しいTweetDeckではButtonSetter', () => {
window.location = new URL('https://tweetdeck.twitter.com');
document.querySelector('body').insertAdjacentHTML('beforeend', '<div id="react-root"></div>');
expect(getButtonSetter()).toBeInstanceOf(ButtonSetter);
describe('新しいTweetDeckではButtonSetter', () => {
it('tweetdeck.twitter.com', () => {
window.location = new URL('https://tweetdeck.twitter.com');
document.querySelector('body').insertAdjacentHTML('beforeend', '<div id="react-root"></div>');
expect(getButtonSetter()).toBeInstanceOf(ButtonSetter);
});
it('pro.twitter.com', () => {
window.location = new URL('https://pro.twitter.com');
document.querySelector('body').insertAdjacentHTML('beforeend', '<div id="react-root"></div>');
expect(getButtonSetter()).toBeInstanceOf(ButtonSetter);
});
});
it('どちらでもなかったらButtonSetter', () => {
window.location = new URL('https://hoge.test');
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.
3 changes: 2 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": "5.3.0",
"version": "5.4.0",
"description": "twitterの画像ツイートにボタンを追加する拡張機能。追加されたボタンを押すとツイートの画像を原寸で新しいタブに表示する。連絡先: @hogextend",
"author": "hogashi",
"permissions": ["tabs", "storage"],
Expand All @@ -16,6 +16,7 @@
"https://twitter.com/*",
"https://mobile.twitter.com/*",
"https://tweetdeck.twitter.com/*",
"https://pro.twitter.com/*",
"https://pbs.twimg.com/*"
],
"js": ["js/main.bundle.js"]
Expand Down
4 changes: 3 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ 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 SHOW_ON_TWEETDECK_TIMELINE = 'SHOW_ON_TWEETDECK_TIMELINE';
export const SHOW_ON_TWEETDECK_TWEET_DETAIL = 'SHOW_ON_TWEETDECK_TWEET_DETAIL';
// 画像ページ
Expand All @@ -72,7 +73,8 @@ export const STRIP_IMAGE_SUFFIX = 'STRIP_IMAGE_SUFFIX';
export const isTwitter = (): boolean =>
window.location.hostname === HOST_TWITTER_COM || window.location.hostname === HOST_MOBILE_TWITTER_COM;
/** Tweetdeckかどうか */
export const isTweetdeck = (): boolean => window.location.hostname === HOST_TWEETDECK_TWITTER_COM;
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;

Expand Down

0 comments on commit 8cd4a91

Please sign in to comment.