addScriptsMenu

Add a "Scripts" section in the WME menu

สคริปต์นี้ไม่ควรถูกติดตั้งโดยตรง มันเป็นคลังสำหรับสคริปต์อื่น ๆ เพื่อบรรจุด้วยคำสั่งเมทา // @require https://update.greatest.deepsurf.us/scripts/485913/1318893/addScriptsMenu.js

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey to install this script.

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         addScriptsMenu
// @namespace    https://greatest.deepsurf.us/fr/users/4324-sebiseba
// @version      2024.01.28
// @description  Add a "Scripts" section in the WME menu
// @author       Sebiseba
// @include      https://beta.waze.com/*editor*
// @include      https://www.waze.com/*editor*
// @exclude      https://www.waze.com/*user/editor/*
// @grant        GM_xmlhttpRequest
// ==/UserScript==
 
/* global $ */
/* jshint esversion:6 */

(function addScriptsMenu() {
        if (typeof getElementsByClassName('collapsible-GROUP_SCRIPTS', getId('layer-switcher-region')) [0] != 'object') {
            var menuParent = getElementsByClassName('togglers', getId('layer-switcher-region')) [0];

            var scriptMenu = document.createElement('li');
            scriptMenu.className="group";

            var scriptMenuContent = document.createElement('div');
            scriptMenuContent.className='layer-switcher-toggler-tree-category';
            scriptMenuContent.innerHTML='<wz-button id="developScript" color="clear-icon" size="xs"><i class="toggle-category w-icon w-icon-caret-down"></i></wz-button>'+
                '<wz-toggle-switch disabled="false" checked id="layer-switcher-group_scripts_" class="layer-switcher-group_scripts_" tabindex="0" name="" value=""></wz-toggle-switch>'+
                '<label class="label-text" for="layer-switcher-group_scripts_">Scripts</label>';
            scriptMenu.appendChild(scriptMenuContent);

            var groupScripts = document.createElement('ul');
            groupScripts.className="collapsible-GROUP_SCRIPTS";
            scriptMenu.appendChild(groupScripts);

            menuParent.insertBefore(scriptMenu, menuParent.firstChild);

            getId('developScript').addEventListener('click', function(e) {
                if (groupScripts.className == 'collapsible-GROUP_SCRIPTS') {
                    groupScripts.className='collapsible-GROUP_SCRIPTS collapse-layer-switcher-group';
                    this.innerHTML='<i class="toggle-category w-icon w-icon-caret-down upside-down"></i>';
                } else {
                    groupScripts.className='collapsible-GROUP_SCRIPTS';
                    this.innerHTML='<i class="toggle-category w-icon w-icon-caret-down"></i>';
                }
            });
            getId('layer-switcher-group_scripts_').addEventListener('click', function(e) {
                if (groupScripts.className == 'collapsible-GROUP_SCRIPTS') {
                    groupScripts.className='collapsible-GROUP_SCRIPTS collapse-layer-switcher-group';
                    getId('developScript').innerHTML='<i class="toggle-category w-icon w-icon-caret-down upside-down"></i>';
                } else {
                    groupScripts.className='collapsible-GROUP_SCRIPTS';
                    getId('developScript').innerHTML='<i class="toggle-category w-icon w-icon-caret-down"></i>';
                }
            });
        }
    }
)