From e9de9f3d1e8fb4b31f003dd9a622a7786d389248 Mon Sep 17 00:00:00 2001 From: sienori Date: Sat, 23 Feb 2019 22:43:22 +0900 Subject: [PATCH] Separate file of personal URLs --- src/common/personalUrls.js | 6 ++++++ src/options/components/InformationPage.js | 11 ++--------- src/popup/components/Header.js | 9 ++------- 3 files changed, 10 insertions(+), 16 deletions(-) create mode 100644 src/common/personalUrls.js diff --git a/src/common/personalUrls.js b/src/common/personalUrls.js new file mode 100644 index 0000000..1ae3510 --- /dev/null +++ b/src/common/personalUrls.js @@ -0,0 +1,6 @@ +import browserInfo from "browser-info"; + +const browserName = browserInfo().name; +const suffix = browserName === "Chrome" ? "fc" : browserName === "Opera" ? "fo" : ""; +export const email = `sienori.firefox+st${suffix}@gmail.com`; +export const paypalLink = `https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&no_shipping=1&business=sienori.firefox@gmail.com&item_name=Simple Translate for ${browserName} - Donation`; diff --git a/src/options/components/InformationPage.js b/src/options/components/InformationPage.js index d82fe46..0eb837a 100644 --- a/src/options/components/InformationPage.js +++ b/src/options/components/InformationPage.js @@ -3,17 +3,12 @@ import browser from "webextension-polyfill"; import browserInfo from "browser-info"; import queryString from "query-string"; import OptionsContainer from "./OptionContainer"; +import { paypalLink, email } from "src/common/personalUrls"; import manifest from "src/manifest-chrome.json"; export default props => { const query = queryString.parse(props.location.search); - const extensionVersion = manifest.version; - const isChrome = browserInfo().name == "Chrome"; - const paypalLink = `https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&no_shipping=1&business=sienori.firefox@gmail.com&item_name=Simple Translate ${ - isChrome ? "for Chrome " : "" - }- Donation`; - const email = `sienori.firefox+st${isChrome ? "fc" : ""}@gmail.com`; return (
@@ -83,9 +78,7 @@ export default props => { } target="_blank" > - {browserInfo().name === "Firefox" - ? browser.i18n.getMessage("addonPageLabel") - : browser.i18n.getMessage("extensionPageLabel")} + {browser.i18n.getMessage("addonPageLabel")}   diff --git a/src/popup/components/Header.js b/src/popup/components/Header.js index 53ca3cd..44a219d 100644 --- a/src/popup/components/Header.js +++ b/src/popup/components/Header.js @@ -1,18 +1,13 @@ import React from "react"; import browser from "webextension-polyfill"; -import browserInfo from "browser-info"; import openUrl from "src/common/openUrl"; +import { paypalLink } from "src/common/personalUrls"; import HeartIcon from "../icons/heart.svg"; import SettingsIcon from "../icons/settings.svg"; import "../styles/header.scss"; -//TODO: 次のタブで開く const openPayPal = () => { - const isChrome = browserInfo().name === "Chrome"; - const url = `https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&no_shipping=1&business=sienori.firefox@gmail.com&item_name=SimpleTranslate ${ - isChrome ? "for Chrome " : "" - }- Donation`; - openUrl(url); + openUrl(paypalLink); }; const openSettings = () => { const url = "../options/index.html#settings";