From 9a31bdf958aa0c547559893f69735644f4476f07 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 13 Mar 2019 12:09:55 +0800 Subject: [PATCH] Redirect url for Yinxiang --- index.js | 4 ++-- src/url.js | 3 ++- src/util.js | 4 ++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index c54e5f5..75060bf 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ 'use strict'; const {app, BrowserWindow, ipcMain, Menu, shell} = require('electron'); const fs = require('fs'); -const {is, formatTitle, formatURL, readSheet} = require('./src/util'); +const {is, formatTitle, formatURL, formatYinxiangURL, readSheet} = require('./src/util'); const file = require('./src/file'); const menu = require('./src/menu'); const pdf = require('./src/pdf'); @@ -95,7 +95,7 @@ app.on('ready', () => { webContents.on('new-window', (e, url) => { e.preventDefault(); - url = formatURL(url); + url = settings.get('useYinxiang') ? formatYinxiangURL(url) : formatURL(url); if (is.downloadURL(url)) { webContents.downloadURL(url); diff --git a/src/url.js b/src/url.js index 64e92ed..53356cc 100644 --- a/src/url.js +++ b/src/url.js @@ -14,5 +14,6 @@ module.exports = { settings: 'https://www.evernote.com/Settings.action', source: 'https://github.com/klaussinani/tusk', update: 'https://klaussinani.github.io/tusk/update.json', - yinxiang: 'https://app.yinxiang.com/Login.action' + yinxiang: 'https://app.yinxiang.com/Login.action', + yinxiangRedirect: 'https://app.yinxiang.com/OutboundRedirect.action?dest=', }; diff --git a/src/util.js b/src/util.js index db67a78..37128ba 100644 --- a/src/util.js +++ b/src/util.js @@ -40,6 +40,10 @@ class Util { return decodeUri(x.replace(url.redirect, '')); } + formatYinxiangURL(x) { + return decodeUri(x.replace(url.yinxiangRedirect, '')); + } + readSheet(x) { return fs.readFileSync(join(__dirname, './style', x), 'utf8'); }