From b436bfcf667e47254d974dd8e508326b6c29b8aa Mon Sep 17 00:00:00 2001 From: cjh0613 Date: Wed, 12 May 2021 16:16:52 +0800 Subject: [PATCH] Support for submitting URLs to Google using the system http proxy --- README.md | 11 +++++++---- lib/google_submitter.js | 6 ++++++ package.json | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 87ef1ca..95bcd33 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ ![峡州仙士](https://cdn.jsdelivr.net/gh/cjh0613/blog/images/icons/CJHicon.jpg) -The project is being tested publicly, welcome to use and submit feedback! +English: The project is being tested publicly, welcome to use and submit feedback! -项目正公开测试,欢迎使用并提交反馈! +中文:项目正公开测试,欢迎使用并提交反馈! 官方交流 QQ 群:[1079685183 点击直接调用 QQ 添加(凑人数)](https://qm.qq.com/cgi-bin/qm/qr?k=POn3F_D9aGvz3sBLO-qwUkaQT7kWzwkC&jump_from=webapi) @@ -62,9 +62,10 @@ hexo_submit_urls_to_search_engine: bing_host: https://cjh0613.github.io ## Domain name registered in Bing webmaster platform bing_token: xxxxx ## Please note that this is your secret key, so do not publish the website source code in the public repository! google_host: https://cjh0613.github.io ## Domain name registered in Google webmaster platform - google_key_file: Project.json #Store the json file of the google key in the root directory of the website (same location as the hexo _config.yml file), please do not publish the source code of the website in the public warehouse! + google_key_file: Project.json # Store the json file of the google key in the root directory of the website (same location as the hexo _config.yml file), please do not publish the source code of the website in the public warehouse! + google_proxy: 0 # Set the proxy used to submit urls to Google replace: 0 # Whether to replace some substrings in links, optional value: 1 | 0 (0: no; 1: yes) - find_what: http://ycjh0613.github.io/blog + find_what: http://cjh0613.github.io/blog replace_with: https://cjh0613.com ``` @@ -88,7 +89,9 @@ And enjoy! success response: ``` Bing response: { d: null } + Baidu response: {"remain":2999,"success":1} + Google response: { urlNotificationMetadata: { url: 'https://cjh0613.github.io', diff --git a/lib/google_submitter.js b/lib/google_submitter.js index 61fddf8..6843b44 100644 --- a/lib/google_submitter.js +++ b/lib/google_submitter.js @@ -11,6 +11,12 @@ module.exports = function (args) { var config = this.config; var googleswitch = config.hexo_submit_urls_to_search_engine.google; if (googleswitch == 1) { + var cjh_google_proxy = config.hexo_submit_urls_to_search_engine.google_proxy; + if (cjh_google_proxy != 0) { + google.options({proxy: cjh_google_proxy}); + process.env.HTTPS_PROXY = cjh_google_proxy; + process.env.HTTP_PROXY = cjh_google_proxy; + } var urlsPath = config.hexo_submit_urls_to_search_engine.txt_path; var host = config.hexo_submit_urls_to_search_engine.google_host; var google_key_file = config.hexo_submit_urls_to_search_engine.google_key_file; diff --git a/package.json b/package.json index 096d2d4..07277b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-submit-urls-to-search-engine", - "version": "2.0.0", + "version": "2.1.0", "description": "Submit new posts urls to Google,Bing,Baidu search engine to improve the quality and speed of website collection", "main": "index.js", "scripts": { @@ -25,7 +25,7 @@ "url": "https://en.cjh0613.com/" }, "license": "GPL-3.0-only", - "dependencies": { + "dependencies": { "xmlhttprequest": "^1.8.0", "request": "^2.88.2", "googleapis": "^52.1.0"