Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Переключатель темы
- // @version 0.1
- // @description Добавляет две кнопки для переключение темы, вместо кнопки "Показать QR-код"
- // @author You
- // @match https://vk.com/app*
- // @grant unsafeWindow
- // @run-at document-idle
- // ==/UserScript==
- (function() {
- 'use strict';
- const b = document.createElement("div");
- b.style="all: unset; color: var(--text_link); cursor: pointer; font-size: 13px; padding-right: 4px;"
- const b1 = document.createElement("button");
- b1.innerText = `Светлая`
- b1.onclick=()=>{
- const iframe=document.body.querySelector("#wrap3 iframe")
- iframe.contentWindow.postMessage({
- "type": "VKWebAppUpdateConfig",
- "data": {
- "appearance": "light",
- "scheme": "vkcom_light"
- }
- },"*")
- };
- b1.style.all="inherit"
- b1.style.paddingRight="10px"
- const b2 = document.createElement("button");
- b2.innerText = `Тёмная`
- b2.onclick=()=>{
- const iframe=document.body.querySelector("#wrap3 iframe")
- iframe.contentWindow.postMessage({
- "type": "VKWebAppUpdateConfig",
- "data": {
- "appearance": "dark",
- "scheme": "vkcom_dark"
- }
- },"*")
- };
- b2.style.all="inherit"
- b.append(b1,b2)
- const observer = new MutationObserver(()=>{
- const qr = document.body.querySelector("#qr_code_btn");
- if (qr) {
- qr.parentNode.prepend(b)
- qr.remove();
- }
- });
- observer.observe(document.querySelector("#wrap3"), {childList: true, subtree: true});
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement