diff options
author | Ajay <[email protected]> | 2023-06-21 23:07:09 -0400 |
---|---|---|
committer | Ajay <[email protected]> | 2023-06-21 23:07:09 -0400 |
commit | b4adee720f76e5d166935e5c89b8c081868d5c11 (patch) | |
tree | 0160bac7e0ce4a954161798abd4e39b1cb021c75 /src/content.ts | |
parent | d4f668559c737018f8ee4ab40c9d152827f0c528 (diff) | |
download | SponsorBlock-b4adee720f76e5d166935e5c89b8c081868d5c11.tar.gz SponsorBlock-b4adee720f76e5d166935e5c89b8c081868d5c11.zip |
Add notice about dearrow, make dearrow links not appear if dearrow installed
Diffstat (limited to 'src/content.ts')
-rw-r--r-- | src/content.ts | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/content.ts b/src/content.ts index 198fa960..ecdba9bf 100644 --- a/src/content.ts +++ b/src/content.ts @@ -36,12 +36,14 @@ import { isFirefoxOrSafari, waitFor } from "@ajayyy/maze-utils"; import { getErrorMessage, getFormattedTime } from "@ajayyy/maze-utils/lib/formating"; import { getChannelIDInfo, getVideo, getIsAdPlaying, getIsLivePremiere, setIsAdPlaying, checkVideoIDChange, getVideoID, getYouTubeVideoID, setupVideoModule, checkIfNewVideoID, isOnInvidious, isOnMobileYouTube } from "@ajayyy/maze-utils/lib/video"; import { Keybind, StorageChangesObject, isSafari, keybindEquals } from "@ajayyy/maze-utils/lib/config"; -import { findValidElement } from "@ajayyy/maze-utils/lib/dom" +import { findValidElement, waitForElement } from "@ajayyy/maze-utils/lib/dom" import { getHash, HashedValue } from "@ajayyy/maze-utils/lib/hash"; import { generateUserID } from "@ajayyy/maze-utils/lib/setup"; import { updateAll } from "@ajayyy/maze-utils/lib/thumbnailManagement"; import { setupThumbnailListener } from "./utils/thumbnails"; import * as documentScript from "../dist/js/document.js"; +import { Tooltip } from "./render/Tooltip"; +import { isDeArrowInstalled } from "./utils/crossExtension"; const utils = new Utils(); @@ -49,6 +51,42 @@ utils.wait(() => Config.isReady(), 5000, 10).then(() => { // Hack to get the CSS loaded on permission-based sites (Invidious) addCSS(); setCategoryColorCSSVariables(); + + // DeArrow promotion + setTimeout(async () => { + if (document.URL === "https://www.youtube.com/" + && Config.config.showDeArrowPromotion + && Config.config.showUpsells + && Config.config.showNewFeaturePopups + && Math.random() < 0.05) { + + if (!await isDeArrowInstalled()) { + const element = await waitForElement("#contents") as HTMLElement; + if (element) { + Config.config.showDeArrowPromotion = false; + + new Tooltip({ + text: chrome.i18n.getMessage("DeArrowPromotionMessage2"), + linkOnClick: () => window.open("https://dearrow.ajay.app"), + referenceNode: element, + prependElement: element.firstElementChild as HTMLElement, + timeout: 15000, + positionRealtive: false, + containerAbsolute: true, + bottomOffset: "inherit", + topOffset: "-82px", + leftOffset: "0", + rightOffset: "0", + displayTriangle: false, + center: true, + opacity: 1 + }); + } + } else { + Config.config.showDeArrowPromotion = false; + } + } + }, 5000) }); const skipBuffer = 0.003; |