Waze Mobile Enhancements

A userscript that makes the WME more useable in Firefox Mobile

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

  1. // ==UserScript==
  2. // @name Waze Mobile Enhancements
  3. // @namespace http://tomputtemans.com/
  4. // @description A userscript that makes the WME more useable in Firefox Mobile
  5. // @include /^https:\/\/(www|beta)\.waze\.com\/(?!user\/)(.{2,6}\/)?editor.*$/
  6. // @version 0.0.2
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. // Initialisation of the script, this will only run completely one time
  11. function init(e) {
  12. if (e && e.user == null) {
  13. return;
  14. }
  15. // if you require certain features to be loaded, you can add them here
  16. if (typeof I18n === 'undefined' || typeof W === 'undefined' || typeof W.loginManager === 'undefined') {
  17. setTimeout(init, 200);
  18. return;
  19. }
  20. setModeChangeListener();
  21. performScript();
  22. }
  23.  
  24. // Attempt to hook into the controller that can notify us whenever the editor's mode changes
  25. function setModeChangeListener() {
  26. if (!W.app || !W.app.modeController) {
  27. setTimeout(setModeChangeListener, 400);
  28. return;
  29. }
  30. W.app.modeController.model.bind('change:mode', function(model, modeId) {
  31. if (modeId == 0) { // 0 = Default, 1 = Events
  32. performScript();
  33. }
  34. });
  35. }
  36.  
  37. function performScript() {
  38. var viewportMeta = document.createElement('meta');
  39. viewportMeta.name = 'viewport';
  40. viewportMeta.content = 'width=device-width, initial-scale=1';
  41. document.head.appendChild(viewportMeta);
  42. var styleElement = document.createElement('style');
  43. document.head.appendChild(styleElement);
  44. styleElement.sheet.insertRule('.modal-dialog-login { width: 100%; margin: 0; }', 0);
  45. styleElement.sheet.insertRule('.modal-dialog-login .modal-content { width: 350px; }', 0);
  46. styleElement.sheet.insertRule('#login-popup { padding: 10px; width: auto; }', 0);
  47. styleElement.sheet.insertRule('#login-popup .login-popup-content { display: block; }', 0);
  48. styleElement.sheet.insertRule('#login-popup .login-form { padding: 15px; height: auto; }', 0);
  49. styleElement.sheet.insertRule('.modal-dialog-login .login-title { font-size: 19px; }', 0);
  50. styleElement.sheet.insertRule('.login-popup-links, .language-select, .welcome-message p, .title-text { display: none; }', 0);
  51. styleElement.sheet.insertRule('#editor-container, #map { width: auto; }', 0);
  52. }
  53.  
  54. init();