diff --git a/README.md b/README.md index a598cc0..45c1b9e 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,10 @@ ![Instructions.gif](https://s1.ax1x.com/2020/08/19/dQ8R3t.gif) +### v1.7.2 + +- 基金明细加上随机UA + ### v1.7.1 - 海外基金NaN问题优化 diff --git a/package.json b/package.json index 265f2ae..6ccec18 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "utools-fund", - "version": "1.7.1", + "version": "1.7.2", "description": "自选基金助手", "main": "main.ts", "scripts": { diff --git a/src/Helper/UserAgentHelper.ts b/src/Helper/UserAgentHelper.ts new file mode 100644 index 0000000..a1f370b --- /dev/null +++ b/src/Helper/UserAgentHelper.ts @@ -0,0 +1,62 @@ +const USER_AGENT_LIST = [ + // 各种PC端 + // Safari + 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2', + // chrome + 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36', + 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11', + 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16', + // 360 + 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36', + 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko', + // QQ浏览器 + 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; QQBrowser/7.0.3698.400)', + 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; QQDownload 732; .NET4.0C; .NET4.0E)', + // sogou浏览器 + 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.84 Safari/535.11 SE 2.X MetaSr 1.0', + 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SV1; QQDownload 732; .NET4.0C; .NET4.0E; SE 2.X MetaSr 1.0)', + // 各种移动端 + // IPhone + 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5', + // IPod + 'Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5', + // IPAD + 'Mozilla/5.0 (iPad; U; CPU OS 4_2_1 like Mac OS X; zh-cn) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5', + 'Mozilla/5.0 (iPad; U; CPU OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5', + // Android + 'Mozilla/5.0 (Linux; U; Android 2.2.1; zh-cn; HTC_Wildfire_A3333 Build/FRG83D) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1', + 'Mozilla/5.0 (Linux; U; Android 2.3.7; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1', + // QQ浏览器 Android版本 + 'MQQBrowser/26 Mozilla/5.0 (Linux; U; Android 2.3.7; zh-cn; MB200 Build/GRJ22; CyanogenMod-7) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1', + // Android Opera Mobile + 'Opera/9.80 (Android 2.3.4; Linux; Opera Mobi/build-1107180945; U; en-GB) Presto/2.8.149 Version/11.10', + // Android Pad Moto Xoom + 'Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13', + // BlackBerry + 'Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en) AppleWebKit/534.1+ (KHTML, like Gecko) Version/6.0.0.337 Mobile Safari/534.1+', + // WebOS HP Touchpad + 'Mozilla/5.0 (hp-tablet; Linux; hpwOS/3.0.0; U; en-US) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/233.70 Safari/534.6 TouchPad/1.0', + // Nokia N97 + 'Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/20.0.019; Profile/MIDP-2.1 Configuration/CLDC-1.1) AppleWebKit/525 (KHTML, like Gecko) BrowserNG/7.1.18124', + // Windows Phone Mango + 'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; HTC; Titan)', + // UC浏览器 + 'UCWEB7.0.2.37/28/999', + 'NOKIA5700/ UCWEB7.0.2.37/28/999', + // UCOpenwave + 'Openwave/ UCWEB7.0.2.37/28/999', + // UC Opera + 'Mozilla/4.0 (compatible; MSIE 6.0; ) Opera/UCWEB7.0.2.37/28/999', + // 一部分 PC端的 + 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1061.1 Safari/536.3', + 'Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1061.0 Safari/536.3', + 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.24 (KHTML, like Gecko) Chrome/19.0.1055.1 Safari/535.24', + 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/535.24 (KHTML, like Gecko) Chrome/19.0.1055.1 Safari/535.24', +]; + +export default class UserAgentHelper { + static getRandom() { + const index = Math.floor(Math.random() * USER_AGENT_LIST.length); + return USER_AGENT_LIST[index]; + } +} diff --git a/src/features/fundMy.ts b/src/features/fundMy.ts index 9ab8251..f944446 100644 --- a/src/features/fundMy.ts +++ b/src/features/fundMy.ts @@ -5,6 +5,7 @@ import { get } from '@/Helper/HttpHelper'; import { ISearchFundResult } from '@/model/ISearchFundResult'; import { IFundEnt } from '@/model/IFundEnt'; import Mousetrap from '../assets/js/mousetrap.min.js'; +import UserAgentHelper from '@/Helper/UserAgentHelper.js'; // 缓存基金详情 let CACHE_FUND_DB_LIST: DBItem[]; @@ -230,6 +231,7 @@ const showFundDetail = async (fundEnt: Partial) => { // }); } ); + fundDetailUbWindow.webContents.setUserAgent(UserAgentHelper.getRandom()); // fundDetailUbWindow.webContents.openDevTools(); };