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/icon.svg | 1 + recipes/tiktok/index.js | 1 + recipes/tiktok/package.json | 9 +++++++++ recipes/tiktok/webview.js | 22 ++++++++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 recipes/tiktok/icon.svg create mode 100644 recipes/tiktok/index.js create mode 100644 recipes/tiktok/package.json create mode 100644 recipes/tiktok/webview.js (limited to 'recipes/tiktok') diff --git a/recipes/tiktok/icon.svg b/recipes/tiktok/icon.svg new file mode 100644 index 0000000..c043135 --- /dev/null +++ b/recipes/tiktok/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/recipes/tiktok/index.js b/recipes/tiktok/index.js new file mode 100644 index 0000000..dd41f72 --- /dev/null +++ b/recipes/tiktok/index.js @@ -0,0 +1 @@ +module.exports = Ferdium => Ferdium; diff --git a/recipes/tiktok/package.json b/recipes/tiktok/package.json new file mode 100644 index 0000000..5d8e794 --- /dev/null +++ b/recipes/tiktok/package.json @@ -0,0 +1,9 @@ +{ + "id": "tiktok", + "name": "Tiktok", + "version": "1.0.0", + "license": "MIT", + "config": { + "serviceURL": "https://tiktok.com" + } +} 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