From d5245c3e4756bf31f76dced9f2f4f2ade2544e07 Mon Sep 17 00:00:00 2001 From: Delgan Date: Wed, 3 Jan 2024 09:52:06 +0100 Subject: [PATCH] Add new option to customize blank new tab HTML/CSS --- background/settings.ts | 1 + pages/blank.html | 10 ++++++---- pages/loader.ts | 6 ++++++ pages/options.html | 11 +++++++++++ typings/vimium_c.d.ts | 1 + 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/background/settings.ts b/background/settings.ts index 721ee0305..1d074db43 100644 --- a/background/settings.ts +++ b/background/settings.ts @@ -365,6 +365,7 @@ saladict@crimx.com` localeEncoding: "gbk", mouseReachable: true, /** mutable */ newTabUrl: "", + userDefinedNewTab: "", nextPatterns: "\u4e0b\u4e00\u5c01,\u4e0b\u9875,\u4e0b\u4e00\u9875,\u4e0b\u4e00\u7ae0,\u540e\u4e00\u9875\ ,\u4e0b\u4e00\u5f20,next,more,newer,>,\u203a,\u2192,\xbb,\u226b,>>", notifyUpdate: true, diff --git a/pages/blank.html b/pages/blank.html index f853a9653..8cc6f1f6a 100644 --- a/pages/blank.html +++ b/pages/blank.html @@ -1,6 +1,8 @@ - -Blank Page - - + + Blank Page + + + + diff --git a/pages/loader.ts b/pages/loader.ts index 0e3ad8d08..8d8e3e2c4 100644 --- a/pages/loader.ts +++ b/pages/loader.ts @@ -84,6 +84,12 @@ var VApi: VApiTy | undefined, VimiumInjector: VimiumInjectorTy | undefined | nul } return browser_.runtime.lastError }) + storage.get("userDefinedNewTab", (res): void => { + if (!res.userDefinedNewTab) { return } + const userContentBody = document.getElementById('vimium-user-content'); + if (!userContentBody) { return } + userContentBody.insertAdjacentHTML('beforeend', res.userDefinedNewTab); + }); if (browser_.i18n.getMessage("lang1")) { const s = browser_.i18n.getMessage("vblank") s && (document.title = s) diff --git a/pages/options.html b/pages/options.html index ede5705ae..db7c2789d 100644 --- a/pages/options.html +++ b/pages/options.html @@ -520,6 +520,17 @@ + + Custom HTML/CSS for blank page + + + +
+ If the "New tab URL" is configured on "pages/blank.html", it can be customized with static content. +
+ Previous patterns diff --git a/typings/vimium_c.d.ts b/typings/vimium_c.d.ts index 6269cd7e3..ff3bb6a66 100644 --- a/typings/vimium_c.d.ts +++ b/typings/vimium_c.d.ts @@ -343,6 +343,7 @@ declare namespace SettingsNS { grabBackFocus: boolean; showAdvancedCommands: boolean; vomnibarOptions: SelectNVType & VomnibarBackendItems; + userDefinedNewTab: string; } interface FrontUpdateAllowedSettings { showAdvancedCommands: 0;