Waze Mobile Enhancements

A userscript that makes the WME more useable in Firefox Mobile

目前为 2018-03-16 提交的版本。查看 最新版本

// ==UserScript==
// @name        Waze Mobile Enhancements
// @namespace   http://tomputtemans.com/
// @description A userscript that makes the WME more useable in Firefox Mobile
// @include     /^https:\/\/(www|beta)\.waze\.com\/(?!user\/)(.{2,6}\/)?editor.*$/
// @version     0.0.2
// @grant       none
// ==/UserScript==

// Initialisation of the script, this will only run completely one time
function init(e) {
  if (e && e.user == null) {
    return;
  }
  // if you require certain features to be loaded, you can add them here
  if (typeof I18n === 'undefined' || typeof W === 'undefined' ||  typeof W.loginManager === 'undefined') {
    setTimeout(init, 200);
    return;
  }
  setModeChangeListener();
  performScript();
}

// Attempt to hook into the controller that can notify us whenever the editor's mode changes
function setModeChangeListener() {
  if (!W.app || !W.app.modeController) {
    setTimeout(setModeChangeListener, 400);
    return;
  }
  W.app.modeController.model.bind('change:mode', function(model, modeId) {
    if (modeId == 0) { // 0 = Default, 1 = Events
      performScript();
    }
  });
}

function performScript() {
  var viewportMeta = document.createElement('meta');
  viewportMeta.name = 'viewport';
  viewportMeta.content = 'width=device-width, initial-scale=1';
  document.head.appendChild(viewportMeta);
  var styleElement = document.createElement('style');
  document.head.appendChild(styleElement);
  styleElement.sheet.insertRule('.modal-dialog-login { width: 100%; margin: 0; }', 0);
  styleElement.sheet.insertRule('.modal-dialog-login .modal-content { width: 350px; }', 0);
  styleElement.sheet.insertRule('#login-popup { padding: 10px; width: auto; }', 0);
  styleElement.sheet.insertRule('#login-popup .login-popup-content { display: block; }', 0);
  styleElement.sheet.insertRule('#login-popup .login-form { padding: 15px; height: auto; }', 0);
  styleElement.sheet.insertRule('.modal-dialog-login .login-title { font-size: 19px; }', 0);
  styleElement.sheet.insertRule('.login-popup-links, .language-select, .welcome-message p, .title-text { display: none; }', 0);
  styleElement.sheet.insertRule('#editor-container, #map { width: auto; }', 0);
}

init();