Skip to content

Instantly share code, notes, and snippets.

@splintor
Last active November 8, 2022 16:28
Show Gist options
  • Save splintor/4c5191114b0a80d4309339635dd4b051 to your computer and use it in GitHub Desktop.
Save splintor/4c5191114b0a80d4309339635dd4b051 to your computer and use it in GitHub Desktop.
Add metasiteId to Wix site header
// ==UserScript==
// @name Add metaSiteId to Wix sites header
// @namespace https://shmulikf.wixsite.com
// @version 0.1
// @description Make it easy to get the metasiteId of a Wix site
// @author Shmulik Flint
// @match https://*.wixsite.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=wixsite.com
// @downloadURL https://gist.githubusercontent.com/splintor/4c5191114b0a80d4309339635dd4b051/raw
// @updateURL https://gist.githubusercontent.com/splintor/4c5191114b0a80d4309339635dd4b051/raw
// @grant none
// ==/UserScript==
(function() {
'use strict';
function addToHeader() {
const header = document.getElementById('WIX_ADS');
if (!header) {
return;
}
if (document.getElementById('metaSiteIdElement')) {
return;
}
let span = document.createElement("span");
span.style.position = 'absolute';
span.style.fontSize = '1.5em';
span.style.margin = '13px';
span.innerHTML = '<div id="metaSiteIdElement">metasiteId: ' + window.viewerModel.site.metaSiteId + '<a href="#" onclick="">Copy</a></div>';
header.prepend(span);
const link = document.querySelector('#metaSiteIdElement a');
link.style.marginInlineStart = '7px';
link.onclick = e => {
e.preventDefault();
e.stopPropagation();
navigator.clipboard.writeText(window.viewerModel.site.metaSiteId);
link.innerHTML = 'Copied!';
setTimeout(() => { link.innerHTML = 'Copy'; }, 2000);
}
}
addToHeader();
const startInteval = setInterval(addToHeader, 100);
setTimeout(() => clearInterval(startInteval), 8000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment