WME Selection Panel Hider

Hides the selection panel

当前为 2015-04-15 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name          WME Selection Panel Hider
// @version       0.1
// @description   Hides the selection panel
// @match         https://editor-beta.waze.com/*editor/*
// @match         https://www.waze.com/*editor/*
// @grant         none
// @author        JJohnston84
// @namespace     https://greasyfork.org/users/10332
// ==/UserScript==

(function()
{ 
  // Delay Init
  setTimeout(init, 654);
  Waze.loginManager.events.register("login", null, init);

  var hideButtonArea;
  var showButtonArea;
  var hasSelection;
  var suppressSelectionPanel;
  
  function init()
  {
    // Tab creation
    var editPanel = document.getElementById('edit-panel');
    var userPanel = document.getElementById('user-info');
    
    hideButtonArea = document.createElement("div");   
    var hidePanelButton = document.createElement('input');
    hidePanelButton.type = 'button';
    hidePanelButton.value = 'Hide Selection Panel';
    hidePanelButton.onclick = sphHideSelectionPanel;        
    hideButtonArea.appendChild(hidePanelButton);
    
    showButtonArea = document.createElement("div");
    var showPanelButton = document.createElement('input');
    showPanelButton.type = 'button';
    showPanelButton.value = 'Show Selection Panel';
    showPanelButton.onclick = sphShowSelectionPanel;        
    showButtonArea.appendChild(showPanelButton);
    
    editPanel.appendChild(hideButtonArea);
    userPanel.appendChild(showButtonArea);
    
    Waze.selectionManager.events.register("selectionchanged", null, sphSelectionChanged);
    sphUpdateVisibility();
  }
  
  function sphHideSelectionPanel()
  {
    suppressSelectionPanel = true;
    Waze.appPresenter.sidebar.editPanel.hide();
    Waze.appPresenter.sidebar.userTabs.show();
    sphUpdateVisibility();
  }
  
  function sphShowSelectionPanel()
  {
    suppressSelectionPanel = false;
    Waze.appPresenter.sidebar.editPanel.show();
    Waze.appPresenter.sidebar.userTabs.hide();
    sphUpdateVisibility();
  }
  
  function sphSelectionChanged()
  {
    hasSelection = Waze.selectionManager.hasSelectedItems();
    suppressSelectionPanel = suppressSelectionPanel && hasSelection;
    sphUpdateVisibility();
  }  
  
  function sphUpdateVisibility()
  {
    var canSeeShowButton = hasSelection && suppressSelectionPanel;
    var canSeeHideButton = hasSelection && !suppressSelectionPanel;
    
    hideButtonArea.style.display = canSeeHideButton ? 'block' : 'none';
    showButtonArea.style.display = canSeeShowButton ? 'block' : 'none';
  }
  
})();