diff --git a/README.md b/README.md index e10fed6..a765635 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,10 @@ **WARNING:** this relies on undocumented features of Rumble. If Rumble changes their site, this may break. -Add support for capturing the paid Rumble Rants for [Rumble.com](https://rumble.com/) livestreams. +Add support for capturing the paid Rumble Rants for [Rumble.com](https://rumble.com/), gifted subscriptions, and raids for livestreams. Rants are shown past their normal expiration date in the chat. -Rants can be shown as a sidebar on the stream page or in a separate window. After a stream ends, cached data can be -viewed by loading the stream page again. +Rants can be shown as a sidebar on the stream page or in a separate window. After a stream ends, cached data can be viewed by loading the stream page again. Additionally, all cached data can be viewed and managed from the Cached Rants page. @@ -124,6 +123,24 @@ Options: - Unchecked: display as sidebar (Default) - Checked: open as popup +**Include Gifts** + +Include gifted subscriptions in the sidebar + +Options: + +- Unchecked: gifted subscriptions are not captured +- Checked: gifted subscriptions are captured (Default) + +**Include Raids** + +Include incoming raids in the sidebar + +Options: + +- Unchecked: incoming raids are not captured +- Checked: incoming raids are captured (Default) + ### Page Links Click "View Cached Rants" to open the Cached Rants page diff --git a/eslint.config.js b/eslint.config.js index b2c6503..dd7e00b 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -64,6 +64,7 @@ module.exports = [ ...jsdoc.configs.recommended.rules, "prettier/prettier": "error", "sonarjs/todo-tag": "warn", + "sonarjs/cognitive-complexity": "off", "import/no-extraneous-dependencies": ["error", { devDependencies: true }], "no-underscore-dangle": "off", "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }], diff --git a/package.json b/package.json index 3a95643..040f55e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rantstats-extension", - "version": "1.5.0", + "version": "1.5.1", "packageManager": "yarn@4.6.0", "description": "Add support for capturing paid Rumble Rants for Rumble.com livestreams.", "main": "output/pages/content/content.js", diff --git a/src/components/open-chat/open-chat.ts b/src/components/open-chat/open-chat.ts index b340d24..3e32dc7 100644 --- a/src/components/open-chat/open-chat.ts +++ b/src/components/open-chat/open-chat.ts @@ -82,9 +82,10 @@ const addCacheButtonToNode = (parentClassName: string, onclick: () => void): boo } /** - * - * @param parentClassName - * @param onclick + * Add button to open cached data below video player + * @param parentClassName class name of section to add button to + * @param onclick function to handle button click + * @returns true if button added */ const addCacheButtonToActions = (parentClassName: string, onclick: () => void): boolean => { // get related videos list diff --git a/src/components/rants/rant.ts b/src/components/rants/rant.ts index 577098c..800d9c3 100644 --- a/src/components/rants/rant.ts +++ b/src/components/rants/rant.ts @@ -1,4 +1,12 @@ -import { cacheMessage, getAllCachedMessageIds, getBadge, getBadges, getUser, updateCachedMessage } from "../../cache" +import { + cacheMessage, + getAllCachedMessageIds, + getBadge, + getBadges, + getOptions, + getUser, + updateCachedMessage, +} from "../../cache" import { CacheBadge, GiftPurchaseNotification, Notification } from "../../types/cache" import { CONSTS } from "../../types/consts" import { SortOrder } from "../../types/option-types" @@ -396,16 +404,17 @@ const renderRant = async ( } /** - * - * @param messageId - * @param time - * @param text - * @param raidNotification - * @param username - * @param userImage - * @param badges - * @param read - * @param cachePage + * Render a raid notification + * @param messageId id of the message + * @param time Time message was posted + * @param text text of the notification + * @param raidNotification raid notification information + * @param username Username for user + * @param userImage Optional path to profile image + * @param badges badges for user + * @param read true: message should be marked read + * @param cachePage true: data being displayed on cache page + * @returns A void promise */ const renderRaidNotification = async ( messageId: string, @@ -673,19 +682,20 @@ const renderGiftNotification = async ( const GIFTED_REGEX = /Was gifted a membership by (?.+?) / /** - * - * @param text + * Checks if the text indicates the user received a gift + * @param text the notification text + * @returns true if text matches gift receiver text */ export const isGiftReceiver = (text: string): boolean => { return GIFTED_REGEX.exec(text) !== null } /** - * - * @param messageId - * @param time - * @param text - * @param username + * Render a notification + * @param messageId id of the message + * @param time Time message was posted + * @param text text of the notification + * @param username Username for user */ export const addGiftReceiver = (messageId: string, time: string, text: string, username: string): void => { if (text === undefined || text === "") { @@ -813,32 +823,36 @@ export const renderMessage = async ( const messageIdNotification = `${messageId}-notification` + const options = await getOptions() + if (isGiftReceiver(text)) { addGiftReceiver(messageId, time, text, realUsername) } else if (raid_notification) { - await renderRaidNotification( - messageId, - time, - text, - raid_notification, - realUsername, - realUserImage, - badges, - read, - cachePage, - ) + if (options?.includeRaids) + await renderRaidNotification( + messageId, + time, + text, + raid_notification, + realUsername, + realUserImage, + badges, + read, + cachePage, + ) } else if (rant && text !== "") { // subscription may not have a message text so don't render await renderRant(messageId, time, text, rant, realUsername, realUserImage, badges, read, cachePage) } else if (giftPurchaseNotification) { - await renderGiftNotification( - messageIdNotification, - time, - giftPurchaseNotification, - realUsername, - realUserImage, - cachePage, - ) + if (options?.includeRaids) + await renderGiftNotification( + messageIdNotification, + time, + giftPurchaseNotification, + realUsername, + realUserImage, + cachePage, + ) } else if (notification) { await renderNotification(messageIdNotification, time, notification, realUsername, realUserImage, cachePage) } diff --git a/src/manifest.json b/src/manifest.json index 74665ac..52b0cfb 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "RantStats Extension for Rumble.com", - "version": "1.5.0", + "version": "1.5.1", "description": "Add support for capturing paid Rumble Rants for Rumble.com livestreams.", "icons": { "16": "images/icon-16.png", diff --git a/src/pages/options/options.html b/src/pages/options/options.html index 20c4cf8..7e085c7 100644 --- a/src/pages/options/options.html +++ b/src/pages/options/options.html @@ -1,5 +1,5 @@ - + Options | RantStats Extension for Rumble.com @@ -79,11 +79,7 @@

RantStats Extension Options

-
+ +
+
+ +

Include gifted subscriptions in the sidebar

+
+ +
+ +
+
+ +
+
+ +

Include incoming raids in the sidebar

+
+ +
+ +
+