Guest User

Untitled

a guest
Sep 29th, 2018
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. * Panel Actions (A Mod for Vivaldi)
  3. * LonM.vivaldi.net
  4. * No Copyright Reserved
  5. */
  6.  
  7. (function panel_actions(){
  8.     "use strict";
  9.  
  10.     const ZOOM_STEP = 0.1; /*Step amount. 0.1 is 10%*/
  11.  
  12.     /*
  13.     Dictionary of panel actions.
  14.     They will be added to the toolbar in the order specified below.
  15.     key must be unique
  16.     title: string for tooltip
  17.     script: (target, webview) => {}: void. target is button that was clicked. webview is the webview attached to the button
  18.         for content scripts, Call doContentScript with the webview and a () => {}: void
  19.     display: string of html - The innerHTML of the toolbar button
  20.     display_class: string - One or more classes to give the button
  21.     */
  22.     const ACTIONS = {
  23.  
  24.         zoom_out: {
  25.             title: "Decrease zoom",
  26.             script: function(target, webview){
  27.                 webview.getZoom(current => {
  28.                     changeZoom(webview, current -= ZOOM_STEP);
  29.                 });
  30.             },
  31.             display: `-`,
  32.             display_class: `zoom-out`
  33.         },
  34.  
  35.         zoom_reset: {
  36.             title: "Set zoom to 100%",
  37.             script: function(target, webview){
  38.                 changeZoom(webview, 1);
  39.             },
  40.             display: `100%`,
  41.             display_class: `zoom-reset`
  42.         },
  43.  
  44.         zoom_in: {
  45.             title: "Increase zoom",
  46.             script: function(target, webview){
  47.                 webview.getZoom(current => {
  48.                     changeZoom(webview, current += ZOOM_STEP);
  49.                 });
  50.             },
  51.             display: `+`,
  52.             display_class: `zoom-in`
  53.         },
  54.  
  55.         invert: {
  56.             title: "Invert the colours on the page",
  57.             script: function(target, webview){
  58.                 doContentScript(webview, () => {
  59.                     const style_element = document.createElement('style');
  60.                     style_element.innerHTML = `
  61.                         html { background-color: white;}
  62.                         body.inverted {filter: invert(1) hue-rotate(180deg);}
  63.                         body.inverted img,
  64.                         body.inverted video {filter: invert(1) hue-rotate(180deg);}`;
  65.                     document.body.appendChild(style_element);
  66.                     document.body.classList.toggle("inverted");
  67.                 });
  68.             },
  69.             display: `<svg viewBox="-4 -4 20 20" xmlns="http://www.w3.org/2000/svg">
  70.             <path d="M 7.984375 0 A 7.9850645 7.9850645 0 0 0 0 7.984375 A 7.9850645 7.9850645 0 0 0 7.984375 15.970703 A 7.9850645 7.9850645 0 0 0 15.970703 7.984375 A 7.9850645 7.9850645 0 0 0 7.984375 0 z M 7.9960938 0.74804688 L 7.9960938 7.984375 L 7.9960938 15.222656 A 7.2378569 7.2378569 0 0 1 1.7265625 11.603516 A 7.2378569 7.2378569 0 0 1 1.7265625 4.3652344 A 7.2378569 7.2378569 0 0 1 7.9960938 0.74804688 z " fill=""></path>
  71.             </svg>`,
  72.             display_class: "panel-action-invert"
  73.         },
  74.  
  75.         terminate: {
  76.             title: "Kills the panel to free memory. WARNING! This will also kill any tabs using the same process.",
  77.             script: function(target, webview){
  78.                 webview.terminate();
  79.             },
  80.             display: `x`,
  81.             display_class: `panel-action-terminate`
  82.         },
  83.  
  84.         mute: {
  85.             title: "Mute this panel",
  86.             script: function(target, webview){
  87.                 webview.isAudioMuted(mute => {
  88.                     webview.setAudioMuted(!mute);
  89.                     target.innerHTML = mute ? `<svg viewBox="-4 -4 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m 10.425781,0 -5.5410155,4.96094 h -4.234375 v 4.74805 h 4.1074219 l 5.6679686,5.23047 z m 1.767579,1.50782 v 0.59961 c 0.628524,0 1.262682,0.52233 1.751953,1.49023 0.489269,0.96789 0.804686,2.34168 0.804686,3.86133 0,1.51964 -0.315417,2.89148 -0.804686,3.85937 -0.489271,0.9679 -1.123429,1.49219 -1.751953,1.49219 v 0.59961 c 0.949262,0 1.742407,-0.74276 2.287109,-1.82031 0.544702,-1.07756 0.869141,-2.52926 0.869141,-4.13086 0,-1.60161 -0.324439,-3.05525 -0.869141,-4.13281 -0.544702,-1.07755 -1.337847,-1.81836 -2.287109,-1.81836 z m -0.921875,1.97851 v 0.59961 c 0.378754,0 0.787693,0.3227 1.113281,0.9668 0.325586,0.64409 0.539061,1.57016 0.539061,2.5957 1e-6,1.02554 -0.213475,1.95161 -0.539061,2.5957 -0.325588,0.64409 -0.734527,0.9668 -1.113281,0.9668 v 0.59961 c 0.699491,0 1.267416,-0.54311 1.648436,-1.29687 0.381021,-0.75375 0.603517,-1.75774 0.603517,-2.86524 0,-1.1075 -0.222496,-2.11344 -0.603517,-2.86719 -0.38102,-0.75375 -0.948945,-1.29492 -1.648436,-1.29492 z"></path></svg>`
  90.                         : `<svg viewBox="-4 -4 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m 10.425781,-0.1412354 -5.5410155,4.96094 H 0.6503908 v 4.75 h 4.1074217 l 5.6679685,5.2285204 z m 0.853516,4.1211 -0.707031,0.70703 1.917969,1.91797 -1.917969,1.91992 0.707031,0.70703 1.917969,-1.91992 1.919922,1.91992 0.707031,-0.70703 -1.919922,-1.91992 1.919922,-1.91797 -0.707031,-0.70703 -1.919922,1.91796 z"></path></svg>`;
  91.                     target.title = mute ? "Mute this panel" : "Panel Muted. Click to Un-Mute";
  92.                 });
  93.             },
  94.             display: `<svg viewBox="-4 -4 20 20" xmlns="http://www.w3.org/2000/svg">
  95.             <path d="m 10.425781,0 -5.5410155,4.96094 h -4.234375 v 4.74805 h 4.1074219 l 5.6679686,5.23047 z m 1.767579,1.50782 v 0.59961 c 0.628524,0 1.262682,0.52233 1.751953,1.49023 0.489269,0.96789 0.804686,2.34168 0.804686,3.86133 0,1.51964 -0.315417,2.89148 -0.804686,3.85937 -0.489271,0.9679 -1.123429,1.49219 -1.751953,1.49219 v 0.59961 c 0.949262,0 1.742407,-0.74276 2.287109,-1.82031 0.544702,-1.07756 0.869141,-2.52926 0.869141,-4.13086 0,-1.60161 -0.324439,-3.05525 -0.869141,-4.13281 -0.544702,-1.07755 -1.337847,-1.81836 -2.287109,-1.81836 z m -0.921875,1.97851 v 0.59961 c 0.378754,0 0.787693,0.3227 1.113281,0.9668 0.325586,0.64409 0.539061,1.57016 0.539061,2.5957 1e-6,1.02554 -0.213475,1.95161 -0.539061,2.5957 -0.325588,0.64409 -0.734527,0.9668 -1.113281,0.9668 v 0.59961 c 0.699491,0 1.267416,-0.54311 1.648436,-1.29687 0.381021,-0.75375 0.603517,-1.75774 0.603517,-2.86524 0,-1.1075 -0.222496,-2.11344 -0.603517,-2.86719 -0.38102,-0.75375 -0.948945,-1.29492 -1.648436,-1.29492 z"></path>
  96.             </svg>`,
  97.             display_class: `panel-action-mute`
  98.         }/*,
  99.  
  100.         template: {
  101.             title: "",
  102.             script: function(event, webview){
  103.  
  104.             },
  105.             display: ``,
  106.             display_class: ``
  107.         },*/
  108.     };
  109.  
  110.     /**
  111.      * Change the zoom
  112.      * @param webview to update
  113.      * @param zoom new zoom factor
  114.      */
  115.     function changeZoom(webview, zoom){
  116.         webview.setZoom(zoom, () => {
  117.             updateZoomLabel(webview);
  118.         });
  119.     }
  120.  
  121.     /**
  122.      * Update the zoom label
  123.      * @param webview to get zoom value from
  124.      */
  125.     function updateZoomLabel(webview){
  126.         const panelZoom = webview.parentElement.parentElement.querySelector(".zoom-reset");
  127.         if(!panelZoom){
  128.             console.error("[lonm-panel-actions] Panel Zoom Label Missing");
  129.             return;
  130.         }
  131.         webview.getZoom(current => {
  132.             const newValue = Math.floor(current * 100);
  133.             panelZoom.innerHTML = newValue + "%";
  134.         });
  135.     }
  136.  
  137.     /**
  138.      * Inject a script as a content script
  139.      * @param webview to use
  140.      * @param scriptMethod Method to inject
  141.      */
  142.     function doContentScript(webview, scriptMethod){
  143.         const scriptText = "("+scriptMethod+")()";
  144.         webview.executeScript({code: scriptText});
  145.     }
  146.  
  147.     /**
  148.      * Create a panel action button
  149.      * REMARK: For some reason the button click currentTarget is not always the button
  150.      * @param action object
  151.      * @param webview dom object button will attach to
  152.      * @returns dom object
  153.      */
  154.     function createActionButton(action, webview){
  155.         const newBtn = document.createElement("button");
  156.         newBtn.className = action.display_class+" button-toolbar-small mod-panel-action";
  157.         newBtn.innerHTML = action.display;
  158.         newBtn.addEventListener("click", event => {
  159.             let eventSource = event.target;
  160.             while(eventSource.tagName.toLowerCase()!== "button"){
  161.                 eventSource = eventSource.parentElement;
  162.             }
  163.             action.script(eventSource, webview);
  164.         });
  165.         newBtn.title = action.title;
  166.         return newBtn;
  167.     }
  168.  
  169.     /**
  170.      * Add the panel action controls
  171.      * @param panel dom node
  172.      */
  173.     function addPanelControls(panel){
  174.         const alreadyAdded = panel.querySelector("footer");
  175.         if(alreadyAdded){return;}
  176.         const footer = document.createElement("footer");
  177.         const webview = panel.querySelector("webview");
  178.         for(const key in ACTIONS){
  179.             const action = ACTIONS[key];
  180.             const newButton = createActionButton(action, webview);
  181.             footer.appendChild(newButton);
  182.         }
  183.         panel.appendChild(footer);
  184.     }
  185.  
  186.     /**
  187.      * upgrade a web panel by adding controls, listeners, etc.
  188.      * @param panel dom node
  189.      */
  190.     function upgradePanel(panel){
  191.         addPanelControls(panel);
  192.         const webview = panel.querySelector("webview");
  193.         webview.addEventListener("zoomchange", () => {
  194.             updateZoomLabel(webview);
  195.         });
  196.         webview.addEventListener("loadcommit", () => {
  197.             updateZoomLabel(webview);
  198.         });
  199.     }
  200.  
  201.     /**
  202.      * Observe changes to the panels
  203.      * Remark: This will either be to upgrade a panel when it is first created
  204.      *    or to re-add the panel controls if removed after a panel was toggled
  205.      */
  206.     const PANEL_CHANGE_OBSERVER = new MutationObserver(records => {
  207.         records.forEach(record => {
  208.             if(record.type==="attributes"){
  209.                 const targetClasses = record.target.classList;
  210.                 if(targetClasses.contains("visible") && targetClasses.contains("webpanel")){
  211.                     addPanelControls(record.target);
  212.                 }
  213.             } else if (record.type==="childList") {
  214.                 record.addedNodes.forEach(node => {
  215.                     if(node.classList && node.classList.contains("webpanel")){
  216.                         upgradePanel(node);
  217.                     }
  218.                 });
  219.             }
  220.         });
  221.     });
  222.  
  223.     /**
  224.      * Begin observing the changes to panels
  225.      * @param webPanelStack The web panel stack div
  226.      */
  227.     function beginObservation(webPanelStack){
  228.         PANEL_CHANGE_OBSERVER.observe(webPanelStack, {
  229.             attributes: true,
  230.             attributeFilter: ["class"],
  231.             childList: true,
  232.             subtree: true
  233.         });
  234.     }
  235.  
  236.     /**
  237.      * Initialise the mod
  238.      */
  239.     function initMod(){
  240.         const webPanels = document.querySelector("#panels");
  241.         if(webPanels){
  242.             beginObservation(webPanels);
  243.             const alreadyOpenPanel = document.querySelector(".panel.webpanel.visible");
  244.             if(alreadyOpenPanel){
  245.                 upgradePanel(alreadyOpenPanel);
  246.             }
  247.         } else { setTimeout(initMod, 500); }
  248.     }
  249.  
  250.     /* Start 500ms after the browser is opened */
  251.     setTimeout(initMod, 500);
  252. })();
  253.  
  254. /*
  255. * Site Security Box Favicons (a mod for Vivaldi)
  256. * Written by LonM
  257. * No Copyright Reserved
  258. * This mod takes the favicon from a tab and places it into the address bar site info box
  259. * Assumes presence of both the tab bar and the address bar
  260. */
  261.  
  262. // Constant CSS Selectors
  263. const SECURITY_ZONE_ICON = "div.addressfield > button.button-addressfield.addressfield-siteinfo > div > svg";
  264. const ACTIVE_TAB = ".tab.active .favicon";
  265. const SECURITY_ZONE = "div.addressfield > button.button-addressfield.addressfield-siteinfo > div.siteinfo-symbol";
  266.  
  267. // Selectors and config for observers
  268. const BROWSER_STATE_INDICATOR = "#browser"
  269. const BROWSER_STATE_INDICATOR_CONFIG = {attributes: true}
  270. const TAB_CHANGE_INDICATOR = ".tab-strip";
  271. const TAB_CHANGE_INDICATOR_CONFIG = {attributes: true, subtree: true}
  272.  
  273. // Observer for changes to tab and browser state
  274. const browserStateChangeObserver = new MutationObserver(browser_state_changed)
  275. const differentTabActivatedObserver = new MutationObserver(tab_changed);
  276.  
  277. // The browser changed state,
  278. // May need to re-observe deleted elements
  279. // E.g. if enter and exit of fullscreen / hide UI mode
  280. function browser_state_changed(m, o){
  281.     //console.log("BROWSER STATE CHANGE");
  282.     remove_existing_cloned_favicon();
  283.     clone_favicon_and_add_to_security();
  284.     differentTabActivatedObserver.disconnect();
  285.     browserStateChangeObserver.disconnect();
  286.     load_favicon_security_mod();
  287. }
  288.  
  289. // The tab was changed, so favicon needs changing
  290. // this will cover changes to the .active tab AND
  291. // cover changes to the favicon span thru subtree
  292. function tab_changed(m, o){
  293.     //console.log("TAB STRIP ATTRIBUTE CHANGE");
  294.     clone_favicon_and_add_to_security();
  295. }
  296.  
  297. // Clone the favicon and add a copy to the security zone
  298. // also style it appropriately
  299. function clone_favicon_and_add_to_security(){
  300.     // make sure everything we need to access exists
  301.     const sz_icon = document.querySelector(SECURITY_ZONE_ICON);
  302.     const favicon_original = document.querySelector(ACTIVE_TAB);
  303.     const siteinfo = document.querySelector(SECURITY_ZONE);
  304.     if(!favicon_original || !sz_icon || !siteinfo){return;}
  305.     remove_existing_cloned_favicon();
  306.     // copy, style and set the favicon
  307.     // use deep clone to also copy svg icons
  308.     const favicon = favicon_original.cloneNode(true);
  309.     favicon.style.width = "16px";
  310.     favicon.style.height = "16px";
  311.     favicon.style.display = "block";
  312.     favicon.style.margin = "3px";
  313.     siteinfo.style.display = "flex";
  314.     sz_icon.parentNode.insertBefore(favicon, sz_icon);
  315. }
  316.  
  317. // Remove any existing cloned favicon
  318. function remove_existing_cloned_favicon(){
  319.     const old_sz_favicon = document.querySelector(SECURITY_ZONE+" .favicon");
  320.     if(old_sz_favicon){
  321.         old_sz_favicon.parentElement.removeChild(old_sz_favicon);
  322.     }
  323. }
  324.  
  325. // Load the mod
  326. function load_favicon_security_mod(){
  327.     const browser = document.querySelector(BROWSER_STATE_INDICATOR)
  328.     const tab_change_indicator = document.querySelector(TAB_CHANGE_INDICATOR);
  329.     if (browser && tab_change_indicator) {
  330.         browserStateChangeObserver.observe(browser, BROWSER_STATE_INDICATOR_CONFIG);
  331.         differentTabActivatedObserver.observe(tab_change_indicator, TAB_CHANGE_INDICATOR_CONFIG);
  332.         clone_favicon_and_add_to_security();
  333.     } else {
  334.         setTimeout(load_favicon_security_mod, 100);
  335.     }
  336. }
  337.  
  338. // BROWSER LOADED - entry point
  339. setTimeout(load_favicon_security_mod, 500);
  340.  
  341. // Fixes the white flash when navigating away from the start page and the white blank page, by setting their color to the current theme's background color.
  342. (function() {
  343.     var bodyStyles, colorBg;
  344.     var observer = new MutationObserver(getBgColor);
  345.  
  346.     observer.observe(document.body, {
  347.         attributes: true,
  348.         attributeFilter: ['style']
  349.     });
  350.  
  351.     function getBgColor() {
  352.         bodyStyles = window.getComputedStyle(document.body);
  353.         colorBg = bodyStyles.getPropertyValue('--colorBg');
  354.         chrome.tabs.query({}, tabs => {
  355.             tabs.forEach(tab => injectScript(tab.url, tab.id));
  356.         });
  357.     }
  358.  
  359.     chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => injectScript(tab.url, tab.id));
  360.  
  361.     function injectScript(tabUrl, tabId) {
  362.         if(tabUrl === "about:blank" || tabUrl === "chrome-extension://mpognobbkildjkofajifpdfhcoklimli/components/startpage/startpage.html") {
  363.             var css =`
  364.             * {
  365.                 background-color: ${colorBg} !important;
  366.             }`;
  367.             var addCss =
  368.             `if(!cssText){
  369.                 var cssText = document.createElement('style');
  370.                 cssText.setAttribute('description', 'Added by white-flash-fix.js');
  371.             }
  372.             cssText.textContent = \`${css}\`;
  373.             document.head.appendChild(cssText);`;
  374.             chrome.tabs.executeScript(tabId, {code: addCss, allFrames: true});
  375.         }
  376.     }
  377. })();
  378.  
  379.  
  380.  
  381. /* Panel Toggle */
  382.  
  383. function panelToggle() {
  384.     const adr = document.querySelector('.toolbar-addressbar.toolbar');
  385.     var panel = document.getElementById('panels-container');
  386.     var paneltog = document.querySelector('.paneltogglefooter');
  387.     var panelsvg = document.querySelector('.paneltogglefooter svg');
  388.     var panelpath = document.querySelector('.paneltogglefooter svg path');
  389.     var sright = 'd: path("M20 8v10h-14v-10h14zm-2 8v-6h-4v6h4z")';
  390.     var sleft = 'd: path("M20 8v10h-14v-10h14zm-8 8v-6h-4v6h4z")';
  391.     paneltog.classList.add('button-toolbar');
  392.     paneltog.classList.remove('button-toolbar-small');
  393.     paneltog.style.order = 'unset';
  394.     panelsvg.style.transform = 'none';
  395.     panelsvg.setAttributeNS(null, 'viewBox', '0 0 26 26');
  396.  
  397.     if (panel.classList.contains('right')) {
  398.         adr.appendChild(paneltog);
  399.         var pof = sright;
  400.         var pon = sleft;
  401.     }
  402.     else {
  403.         adr.insertBefore(paneltog,adr.firstChild);
  404.         var pof = sleft;
  405.         var pon = sright;
  406.     }
  407.     if (panel.classList.contains('switcher')) {
  408.         panelpath.style = pof;
  409.     }
  410.     else {
  411.         panelpath.style = pon;
  412.     }
  413.  
  414.     paneltog.addEventListener('click', function(event) {
  415.         if (!event.altKey) {
  416.             if (panel.classList.contains('switcher')) {
  417.                 panelpath.style = pon;
  418.             }
  419.             else {
  420.                 panelpath.style = pof;
  421.             }
  422.         }
  423.     });
  424. };
  425.  
  426.  
  427. /* Tools Menu */
  428.  
  429. function create() {
  430.     const adr = document.querySelector('.toolbar-addressbar.toolbar');
  431.     const footer = document.getElementById('footer')
  432.     footer.classList.add('disabled','zeig');
  433.     var spanT = document.createElement('span');
  434.     var divT = document.createElement('div');
  435.     divT.id = 'droptool';
  436.     var btnT = document.createElement('button');
  437.     btnT.id = 'tools';
  438.     btnT.classList.add('button-toolbar');
  439.     btnT.setAttribute('tabindex', '-1');
  440.     btnT.setAttribute('title', 'Tools');
  441.     btnT.innerHTML = '<svg width="26" height="26" viewBox="-150 -150 812 812" xmlns="http://www.w3.org/2000/svg"><path d="M483.97,105.709c-2.491-9.958-14.903-13.424-22.157-6.165l-58.913,58.914c-13.083,13.077-34.291,13.077-47.372,0   l-27.03-27.031c-13.082-13.081-13.082-34.289,0-47.372l58.196-58.197c7.307-7.307,3.751-19.838-6.306-22.193   c-13.772-3.218-28.327-4.406-43.339-3.208c-64.522,5.148-123.907,65.649-127.923,130.254c-1.521,24.503,3.43,47.667,13.077,68.186   L16.253,375.878c-9.263,7.96-14.81,19.401-15.323,31.602c-0.519,12.201,4.042,24.068,12.599,32.78l34.902,35.541   c8.64,8.802,20.57,13.586,32.899,13.19c12.33-0.399,23.928-5.936,31.986-15.271l178.388-206.684   c19.917,8.889,42.21,13.424,65.747,11.956c65.041-4.058,125.554-63.92,130.29-128.91   C488.863,134.686,487.482,119.777,483.97,105.709z"></path>';
  442.     var infdiv = document.createElement('div');
  443.     infdiv.id = 'divID';
  444.     infdiv.innerHTML = '<button id="toggle-links" title="Hide Status Info" class="button-toolbar-small" tabindex="-1"><svg width="16" height="16" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><path d="M17.6 20.4l-1.6 1.6-9-9 9-9 1.6 1.6-7.2 7.4 7.2 7.4z" fill="var(--colorHighlightBg)"></path></svg></button>';
  445.     adr.insertBefore(spanT,document.querySelector('.searchfield').nextSibling);
  446.     spanT.appendChild(btnT);
  447.     spanT.appendChild(divT);
  448.     divT.appendChild(footer);
  449.     footer.appendChild(infdiv);
  450. };
  451.  
  452. function cssT() {
  453.     var styleS = document.createElement('style');
  454.     styleS.type = 'text/css';
  455.     styleS.innerHTML = '#droptool {position: absolute;z-index: 1;right: 0;box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);}.callout {bottom: unset;margin-top: 1px;}.callout::before, .callout::after {display: none;}#divID {order: 1 }.sync-status {order: 2;}.status-toolbar {order: 3;}#footer {border-right: none;}#status_info {display: none;}#footer.zeig #status_info.visible {display: flex;max-width: 500px;}';
  456.     document.getElementsByTagName('head')[0].appendChild(styleS);
  457. };
  458.  
  459. function menuT() {
  460.     if (footer.classList.contains('disabled')) {
  461.         footer.classList.remove('disabled');
  462.     }
  463.     else {
  464.         footer.classList.add('disabled');
  465.     }
  466. };
  467.  
  468. function statusT() {
  469.     const fill = document.querySelector('#toggle-links svg path');
  470.     const infbtn = document.getElementById('toggle-links');
  471.     if (footer.classList.contains('zeig')) {
  472.         footer.classList.remove('zeig');
  473.         fill.setAttribute('fill', 'var(--colorFg)');
  474.         infbtn.setAttribute('title', 'Show Status Info');
  475.     }
  476.     else {
  477.         footer.classList.add('zeig');
  478.         fill.setAttribute('fill', 'var(--colorHighlightBg)');
  479.         infbtn.setAttribute('title', 'Hide Status Info');
  480.     }
  481. };
  482.  
  483. function toolsMenu() {
  484.     create();
  485.     cssT();
  486.     document.getElementById('tools').addEventListener('click', menuT);
  487.     document.getElementById('toggle-links').addEventListener('click', statusT);
  488. };
  489.  
  490.  
  491. setTimeout(function wait() {
  492.     const adr = document.querySelector('.toolbar-addressbar.toolbar');
  493.     if (adr) {
  494.         toolsMenu();
  495.         panelToggle();
  496.     }
  497.     else {
  498.         setTimeout(wait, 300);
  499.     }
  500. }, 300);
Advertisement
Add Comment
Please, Sign In to add comment