From f31624ea3cb5745f3ff04e681b820108c849f3bb Mon Sep 17 00:00:00 2001 From: sunx Date: Sun, 1 Dec 2019 10:32:33 +0800 Subject: [PATCH 1/3] fix leetcode.cn login error with [cookie.chrome] plugin host_key error --- plugins/cookie.chrome.js | 7 ++++++- plugins/leetcode.cn.js | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/cookie.chrome.js b/plugins/cookie.chrome.js index e2d4278..ba6671f 100644 --- a/plugins/cookie.chrome.js +++ b/plugins/cookie.chrome.js @@ -134,9 +134,14 @@ Chrome.getCookies = function(cb) { db.on('error', cb); var KEYS = ['csrftoken', 'LEETCODE_SESSION']; + let host = config.sys.cookie_host; + if (!host) { + host = 'leetcode.com'; // default host key + } + db.serialize(function() { var cookies = {}; - var sql = 'select name, encrypted_value from cookies where host_key like "%leetcode.com"'; + var sql = 'select name, encrypted_value from cookies where host_key like "%' + host +'"'; db.each(sql, function(e, x) { if (e) return cb(e); if (KEYS.indexOf(x.name) < 0) return; diff --git a/plugins/leetcode.cn.js b/plugins/leetcode.cn.js index 07d5d2d..8094ba6 100644 --- a/plugins/leetcode.cn.js +++ b/plugins/leetcode.cn.js @@ -31,6 +31,7 @@ plugin.init = function() { config.sys.urls.verify = 'https://leetcode-cn.com/submissions/detail/$id/check/'; config.sys.urls.favorites = 'https://leetcode-cn.com/list/api/questions'; config.sys.urls.favorite_delete = 'https://leetcode-cn.com/list/api/questions/$hash/$id'; + config.sys.cookie_host = 'leetcode-cn.com'; }; // FIXME: refactor those From 47af2df4d9b55ce1d28a5297d9f70dbce2cf43f5 Mon Sep 17 00:00:00 2001 From: sunx Date: Sun, 1 Dec 2019 10:36:00 +0800 Subject: [PATCH 2/3] fix leetcode.cn login error with [cookie.chrome] plugin host_key error --- plugins/cookie.firefox.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/cookie.firefox.js b/plugins/cookie.firefox.js index f69f869..e58dc85 100644 --- a/plugins/cookie.firefox.js +++ b/plugins/cookie.firefox.js @@ -34,9 +34,14 @@ function getCookies(cb) { var db = new sqlite3.Database(files[0]); var KEYS = ['csrftoken', 'LEETCODE_SESSION']; + let host = config.sys.cookie_host; + if (!host) { + host = 'leetcode.com'; // default host key + } + db.serialize(function() { var cookies = {}; - var sql = 'select name, value from moz_cookies where host like "%leetcode.com"'; + var sql = 'select name, value from moz_cookies where host like "%' + host +'"'; db.each(sql, function(e, x) { if (e) return cb(e); if (KEYS.indexOf(x.name) < 0) return; From afbd94edefdc09c43a71a491315528537d50f49a Mon Sep 17 00:00:00 2001 From: sunznx Date: Mon, 2 Dec 2019 09:45:19 +0800 Subject: [PATCH 3/3] update --- plugins/cookie.chrome.js | 1 + plugins/cookie.firefox.js | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/cookie.chrome.js b/plugins/cookie.chrome.js index ba6671f..a0a43f9 100644 --- a/plugins/cookie.chrome.js +++ b/plugins/cookie.chrome.js @@ -4,6 +4,7 @@ var log = require('../log'); var Plugin = require('../plugin'); var Queue = require('../queue'); var session = require('../session'); +var config = require('../config'); // [Usage] // diff --git a/plugins/cookie.firefox.js b/plugins/cookie.firefox.js index e58dc85..ded46bc 100644 --- a/plugins/cookie.firefox.js +++ b/plugins/cookie.firefox.js @@ -1,6 +1,7 @@ var log = require('../log'); var Plugin = require('../plugin'); var session = require('../session'); +var config = require('../config'); // [Usage] //