From ca1b5e152c912622e298c5401a0db4dc62fec4bd Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Thu, 2 May 2024 11:01:00 +0800 Subject: [PATCH] method to universally write current tab --- scripts/data/pointer.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 scripts/data/pointer.js diff --git a/scripts/data/pointer.js b/scripts/data/pointer.js new file mode 100644 index 0000000..bba63f2 --- /dev/null +++ b/scripts/data/pointer.js @@ -0,0 +1,27 @@ +/* pointer.js + +Change the currently selected data to be viewed by the popup. +*/ + +import {global} from "/scripts/secretariat.js"; + +class pointer { + /* + Select a URL to view. + */ + static select(URL) { + const clean = (URL) => { + // Remove the protocol from the URL. + return((URL.replace(/(^\w+:|^)\/\//, ``).split(`?`))[0]); + } + + try { + URL = (!URL) ? window.location.href : ((URL && (typeof URL).includes(`str`)) ? clean(URL) : null); + } catch(err) {} + + // Get the last edited site. + return(global.write([`last`, `URL`], this.URL, -1)); + } +} + +export {pointer as default};