From 95c5fc18d6e9bef47268e6a932d88de9e8cca0d5 Mon Sep 17 00:00:00 2001 From: André Oliveira <37463445+SpecialAro@users.noreply.github.com> Date: Tue, 5 Jul 2022 00:00:33 +0100 Subject: Add Tiktok recipe (#105) Co-authored-by: Vijay A --- recipes/tiktok/webview.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 recipes/tiktok/webview.js (limited to 'recipes/tiktok/webview.js') diff --git a/recipes/tiktok/webview.js b/recipes/tiktok/webview.js new file mode 100644 index 0000000..6f78019 --- /dev/null +++ b/recipes/tiktok/webview.js @@ -0,0 +1,22 @@ +const _path = _interopRequireDefault(require('path')); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; +} + +module.exports = Ferdium => { + const getMessages = () => { + const selNotifications = document.querySelector("div.tiktok-1b4xcc5-DivHeaderInboxContainer.e18kkhh40 > sup"); + const selDM = document.querySelector("div.tiktok-1ibfxbr-DivMessageIconContainer.e1nx07zo0 > sup"); + + const countNotifications = (selNotifications != null) ? Ferdium.safeParseInt(selNotifications.outerText) : 0; + const countDM = (selDM != null) ? Ferdium.safeParseInt(selDM.outerText) : 0; + + const count = countNotifications + countDM; + + Ferdium.setBadge(count); + }; + Ferdium.loop(getMessages); + + Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); +}; -- cgit v1.2.3-70-g09d2