From ec541d2de810903c7d10c7985e0251d002ea221e Mon Sep 17 00:00:00 2001 From: Yoga Setiawan Date: Fri, 5 Mar 2021 17:35:20 +0700 Subject: Add recipe for Erepublik (#443) --- recipes/erepublik/icon.png | Bin 0 -> 80134 bytes recipes/erepublik/icon.svg | 110 +++++++++++++++++++++++++++++++++++++++++ recipes/erepublik/index.js | 2 + recipes/erepublik/package.json | 12 +++++ recipes/erepublik/user.js | 3 ++ recipes/erepublik/webview.js | 41 +++++++++++++++ 6 files changed, 168 insertions(+) create mode 100644 recipes/erepublik/icon.png create mode 100644 recipes/erepublik/icon.svg create mode 100644 recipes/erepublik/index.js create mode 100644 recipes/erepublik/package.json create mode 100644 recipes/erepublik/user.js create mode 100644 recipes/erepublik/webview.js diff --git a/recipes/erepublik/icon.png b/recipes/erepublik/icon.png new file mode 100644 index 0000000..ca16eed Binary files /dev/null and b/recipes/erepublik/icon.png differ diff --git a/recipes/erepublik/icon.svg b/recipes/erepublik/icon.svg new file mode 100644 index 0000000..389adf2 --- /dev/null +++ b/recipes/erepublik/icon.svg @@ -0,0 +1,110 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/recipes/erepublik/index.js b/recipes/erepublik/index.js new file mode 100644 index 0000000..146e5fb --- /dev/null +++ b/recipes/erepublik/index.js @@ -0,0 +1,2 @@ +module.exports = Ferdi => class erepublik extends Ferdi { +}; diff --git a/recipes/erepublik/package.json b/recipes/erepublik/package.json new file mode 100644 index 0000000..9a20fbb --- /dev/null +++ b/recipes/erepublik/package.json @@ -0,0 +1,12 @@ +{ + "id": "erepublik", + "name": "eRepublik", + "version": "1.0.0", + "description": "erepublik", + "main": "index.js", + "author": "Ari Oki ", + "license": "MIT", + "config": { + "serviceURL": "https://erepublik.com" + } +} diff --git a/recipes/erepublik/user.js b/recipes/erepublik/user.js new file mode 100644 index 0000000..b7e3573 --- /dev/null +++ b/recipes/erepublik/user.js @@ -0,0 +1,3 @@ +module.exports = (config, Ferdi) => { + +}; diff --git a/recipes/erepublik/webview.js b/recipes/erepublik/webview.js new file mode 100644 index 0000000..ca55df3 --- /dev/null +++ b/recipes/erepublik/webview.js @@ -0,0 +1,41 @@ +'use strict'; + +var _path = _interopRequireDefault(require('path')); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; +} + +module.exports = Ferdi => { + const getMessages = function getMessages() { + + const elementNotify = document.getElementsByClassName('notify'); + const elementFeed = document.getElementsByClassName('unreadCounter ng-binding ng-scope'); + + let countNotify = 0; + let countFeed = 0; + + for (let i = 0; i < elementNotify.length; i++) { + let splitText = elementNotify[i].title.split(':'); + let badgeNumber = parseInt(splitText[1], 10); + if (badgeNumber) { + countNotify = countNotify + badgeNumber; + } + } + + for (let i = 0; i < elementFeed.length; i++) { + let feedNumber = parseInt(elementFeed[i].textContent, 10); + if (feedNumber) { + countFeed = countFeed + feedNumber; + } + } + + console.log(countNotify, countFeed); + Ferdi.setBadge(countNotify, countFeed); + }; + + + Ferdi.loop(getMessages); + Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); + Ferdi.injectCSS(_path.default.join(__dirname, 'crpk-resources/fonts.css')); +}; -- cgit v1.2.3-70-g09d2