From a6861f436e569c3038990301244ce5d13bf08961 Mon Sep 17 00:00:00 2001 From: Long Date: Sun, 6 Sep 2020 23:09:33 +0700 Subject: [PATCH] =?UTF-8?q?s=E1=BB=ADa=20l=E1=BB=97i=20thay=20th=E1=BA=BF?= =?UTF-8?q?=20to=C3=A0n=20b=E1=BB=99=20b=C3=A0i=20=C4=91=C4=83ng=20d=C3=B9?= =?UTF-8?q?=20ch=E1=BB=89=20c=C3=B3=20b=C3=ACnh=20lu=E1=BA=ADn=20ch?= =?UTF-8?q?=E1=BB=A9a=20t=E1=BB=AB=20kho=C3=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/contentscript.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/scripts/contentscript.js b/scripts/contentscript.js index f591ee5..f3ac465 100644 --- a/scripts/contentscript.js +++ b/scripts/contentscript.js @@ -9,6 +9,7 @@ var ads = false, store = false, contains_keywords = false, keywords = []; +var class_comment_text = "kvgmc6g5 cxmmr5t8 oygrvhab hcukyx3x c1et5uql"; chrome.storage.local.get("opts", function (_ref) { var opts = _ref.opts; @@ -59,12 +60,10 @@ chrome.storage.local.get("opts", function (_ref) { if (contains_keywords) { // bài hoặc bình luận chứa từ khoá for (var i = 0; i < keywords.length; i++) { - div = $("span[class^=\"oi732d6d ik7dh3pa d2edcug0 hpfvmrgz qv66sw1b c1et5uql a8c37x1j muag1w35 enqfppq2 jq4qci2q a3bd9o3v knj5qynh oo9gr5id\"]:contains(".concat(keywords[i], ")")).closest("div[data-pagelet^=\"FeedUnit\"]").first(); + div = getDivPost(keywords[i]); - if (div.length != 0) { - executeDiv(div, chrome.i18n.getMessage('post')); - } else { - $("div[class=\"kvgmc6g5 cxmmr5t8 oygrvhab hcukyx3x c1et5uql\"]:contains(".concat(keywords[i], "):not('.ex-replaced')")).html("\n ".concat(chrome.i18n.getMessage('comment'), " ").concat(chrome.i18n.getMessage('notification'), " ").concat(chrome.i18n.getMessage('appName'), ".\n ")).addClass('ex-replaced'); + if (div.length == 0) { + $("div[class=\"".concat(class_comment_text, "\"]:contains(").concat(keywords[i], "):not('.ex-replaced')")).html("\n ".concat(chrome.i18n.getMessage('comment'), " ").concat(chrome.i18n.getMessage('notification'), " ").concat(chrome.i18n.getMessage('appName'), ".\n ")).addClass('ex-replaced'); } } } @@ -72,6 +71,21 @@ chrome.storage.local.get("opts", function (_ref) { }); })(chrome); +function getDivPost(keyword) { + var class_post_text = ["ecm0bbzt hv4rvrfc ihqw7lf3 dati1w0a", "dati1w0a ihqw7lf3 hv4rvrfc ecm0bbzt"]; + + for (var i = 0; i < class_post_text.length; i++) { + var _div = $("div[data-pagelet^=\"FeedUnit\"]").has("div[class=\"".concat(class_post_text[i], "\"]:contains('").concat(keyword, "')")).first(); + + if (_div.length != 0) { + executeDiv(_div, chrome.i18n.getMessage('post')); + break; + } + } + + return div; +} + function executeDiv(this_div, type) { if (this_div.length !== 0) { // loại bỏ khỏi danh sách cũ