From 0513124dc3b07b70b639b87e9e9c6fea2348f4df Mon Sep 17 00:00:00 2001 From: Pablo Armentano Date: Sat, 21 Aug 2021 15:09:51 -0300 Subject: [PATCH 1/4] New feature: custom favicon and styles --- worker.js | 54 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/worker.js b/worker.js index 17dd635..27a6da7 100644 --- a/worker.js +++ b/worker.js @@ -23,7 +23,13 @@ const PAGE_DESCRIPTION = /* Step 4: enter a Google Font name, you can choose from https://fonts.google.com */ const GOOGLE_FONT = "Rubik"; -/* Step 5: enter any custom scripts you'd like */ +/* Step 5: Add a custom favicon (your Notion avatar URL works too) */ +const CUSTOM_AVATAR = ""; + +/* Step 6: enter any custom CSS, no style tag needed */ +const CUSTOM_STYLE = ``; + +/* Step 7: enter any custom scripts you'd like, script tag needed */ const CUSTOM_SCRIPT = ``; /* CONFIGURATION ENDS HERE */ @@ -175,12 +181,26 @@ class MetaRewriter { } } + class LinkRewriter { + element(element) { + if (element.getAttribute('rel') === 'shortcut icon') { + element.setAttribute('href', CUSTOM_AVATAR); + } + + if (element.getAttribute('rel') === 'apple-touch-icon') { + element.setAttribute('href', CUSTOM_AVATAR); + } + } + } + class HeadRewriter { element(element) { if (GOOGLE_FONT !== "") { - element.append( - ` - `, + element.append(` + `, { html: true } @@ -196,6 +216,8 @@ class HeadRewriter { div.notion-topbar-mobile > div:nth-child(4) { display: none !important; } div.notion-topbar > div > div:nth-child(1n).toggle-mode { display: block !important; } div.notion-topbar-mobile > div:nth-child(1n).toggle-mode { display: block !important; } + + ${CUSTOM_STYLE} `, { html: true @@ -209,8 +231,9 @@ class BodyRewriter { this.SLUG_TO_PAGE = SLUG_TO_PAGE; } element(element) { - element.append( - `