WME Fix UI

Allows alterations to the WME UI to fix things screwed up or ignored by Waze

当前为 2016-06-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name WME Fix UI
  3. // @namespace https://greasyfork.org/en/users/46070
  4. // @description Allows alterations to the WME UI to fix things screwed up or ignored by Waze
  5. // @include https://www.waze.com/editor/*
  6. // @include https://www.waze.com/*/editor/*
  7. // @include https://editor-beta.waze.com/*
  8. // @exclude https://www.waze.com/user/editor/*
  9. // @supportURL https://www.waze.com/forum/viewtopic.php?f=819&t=191178
  10. // @version 1.0
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. // Thanks to (in no particular order) Bellhouse, Twister-UK, Timbones, Dave2084, Rickzabel, Glodenox
  15.  
  16. (function()
  17. {
  18. // global variables
  19. var wmefu_version = "1.0";
  20. var tabAttempts = 0;
  21. var wmeFUAddon;
  22.  
  23. function init1() {
  24. // go round again if map container isn't there yet
  25. if(!window.Waze.map) {
  26. console.log("WMEFU: waiting for WME...");
  27. setTimeout(init1, 200);
  28. return;
  29. }
  30. // create tab content and store it
  31. wmeFUAddon = createAddon();
  32. // insert the content as a tab
  33. addMyTab(null,0);
  34. //pass control to init2
  35. init2();
  36. }
  37.  
  38. function init2() {
  39. //go round again if my tab isn't there yet
  40. if (!getId('sidepanel-FixUI')) {
  41. console.log('WMEFU: waiting for my tab to appear');
  42. setTimeout(init2, 200);
  43. return;
  44. }
  45. // setup event handlers for user actions:
  46. getId('_cbMoveZoomBar').onclick = moveZoomBar;
  47. getId('_cbShrinkBlackBar').onclick = shrinkBlackBar;
  48. getId('_cbHideUserInfo').onclick = hideUserInfo;
  49. getId('_cbCompressSegmentTab').onclick = compressSegmentTab;
  50. getId('_cbRestyleReports').onclick = restyleReports;
  51. getId('_cbDisableMapBlocker').onclick = disableMapBlocker;
  52. getId('_cbNarrowSidePanel').onclick = narrowSidePanel;
  53. getId('_cbHideAveSpeedControls').onclick = hideAveSpeedControls;
  54. // set event to recreate my tab when MTE mode is exited
  55. Waze.app.modeController.model.bind('change:mode', addMyTab);
  56.  
  57. // restore saved settings
  58. if (localStorage.WMEFixUI) {
  59. console.log("WMEFU: loading options");
  60. options = JSON.parse(localStorage.WMEFixUI);
  61. getId('_cbMoveZoomBar').checked = options[1];
  62. getId('_cbShrinkBlackBar').checked = options[2];
  63. getId('_cbHideUserInfo').checked = options[3];
  64. getId('_cbCompressSegmentTab').checked = options[4];
  65. getId('_cbRestyleReports').checked = options[5];
  66. getId('_cbDisableMapBlocker').checked = options[6];
  67. getId('_cbNarrowSidePanel').checked = options[7];
  68. getId('_cbHideAveSpeedControls').checked = options[8];
  69. } else {
  70. // default values if option isn't stored
  71. getId('_cbMoveZoomBar').checked = true;
  72. getId('_cbShrinkBlackBar').checked = true;
  73. getId('_cbHideUserInfo').checked = true;
  74. getId('_cbCompressSegmentTab').checked = true;
  75. getId('_cbRestyleReports').checked = true;
  76. getId('_cbDisableMapBlocker').checked = false;
  77. getId('_cbNarrowSidePanel').checked = false;
  78. getId('_cbHideAveSpeedControls').checked = false;
  79. }
  80.  
  81. // Adds an extra checkbox so I can test segment panel changes easily
  82. if (Waze.loginManager.user.userName == 'iainhouse') {
  83. var brand = getId('brand');
  84. extraCBSection = document.createElement('p');
  85. extraCBSection.innerHTML = '<input type="checkbox" id="_cbextraCBSection" />';
  86. brand.appendChild(extraCBSection);
  87. getId('_cbextraCBSection').onclick = FALSEcompressSegmentTab;
  88. _cbextraCBSection.checked = _cbCompressSegmentTab.checked;
  89. }
  90. // overload the WME exit function to save my settings
  91. saveOptions = function() {
  92. if (localStorage) {
  93. console.log("WMEFU: saving options");
  94. var options = [];
  95.  
  96. // preserve previous options which may get lost after logout
  97. if (localStorage.WMEFixUI)
  98. options = JSON.parse(localStorage.WMEFixUI);
  99. options[1] = getId('_cbMoveZoomBar').checked;
  100. options[2] = getId('_cbShrinkBlackBar').checked;
  101. options[3] = getId('_cbHideUserInfo').checked;
  102. options[4] = getId('_cbCompressSegmentTab').checked;
  103. options[5] = getId('_cbRestyleReports').checked;
  104. options[6] = getId('_cbDisableMapBlocker').checked;
  105. options[7] = getId('_cbNarrowSidePanel').checked;
  106. options[8] = getId('_cbHideAveSpeedControls').checked;
  107. localStorage.WMEFixUI = JSON.stringify(options);
  108. }
  109. };
  110. window.addEventListener("beforeunload", saveOptions, false);
  111.  
  112. // apply the settings
  113. setTimeout(applyAllSettings, 2000);
  114. console.log("WMEFU: Initialised");
  115. }
  116.  
  117. function createAddon() {
  118. //create the contents of my side-panel tab
  119. var addon = document.createElement('section');
  120. var section = document.createElement('p');
  121. addon.id = "sidepanel-FixUI";
  122. section.style.paddingTop = "0px";
  123. section.id = "fuContent";
  124. section.innerHTML = '<b>UI Fixes</b><br>';
  125. section.innerHTML += '<input type="checkbox" id="_cbMoveZoomBar" /> ' +
  126. '<span title="Because nobody likes a pointless UI change that breaks your workflow, imposed by idiots who rarely use the editor and don\'t listen to feedback">Move zoom bar to left <sup>*</sup></span><br>';
  127. section.innerHTML += '<input type="checkbox" id="_cbHideUserInfo" /> ' +
  128. '<span title="Because we can earn points quicker without a massive chunk of space wasted on telling us how many we earnt up to yesterday">Hide user info in the side panel</span><br>';
  129. section.innerHTML += '<input type="checkbox" id="_cbShrinkBlackBar" /> ' +
  130. '<span title="Because we can\'t afford to waste screen space on stuff we didn\'t ask for and don\'t want">Shrink the black bar above the map</span><br>';
  131. section.innerHTML += '<input type="checkbox" id="_cbCompressSegmentTab" /> ' +
  132. '<span title="Because I\'m sick of having to scroll the side panel because of oversized fonts and wasted space">Compress the contents of the side panel</span><br>';
  133. section.innerHTML += '<input type="checkbox" id="_cbRestyleReports" /> ' +
  134. '<span title="Another UI element configured for developers with massive screens instead of normal users">Change formatting for report panels (UR/MP)</span><br>';
  135. section.innerHTML += '<input type="checkbox" id="_cbDisableMapBlocker" /> ' +
  136. '<span title="As if the crappy interface wasn\'t making life hard enough, now they force us to wait for an arbitrary time after every save!">Disable map blocking during/after saving.</span><span title="Use at your own risk. We don\'t know why it\'s there. Maybe there\'s a good reason but Waze can\'t be arsed to tell us what it is." style="font-size: 16px; color: red;">&#9888</span><br>';
  137. section.innerHTML += '<input type="checkbox" id="_cbNarrowSidePanel" /> ' +
  138. '<span title="If you have a netbook, Waze isn\'t interested in your experience. You need every bit of map space you can get - so have a present from me!">Reduce width of the side panel</span><span title="This will definitely interfere with scripts that rely on a fixed width for their tabs." style="font-size: 16px; color: red;">&#9888</span><br>';
  139. section.innerHTML += '<input type="checkbox" id="_cbHideAveSpeedControls" /> ' +
  140. '<span title="If you don\'t have these in your country, YOU\'RE LUCKY! But don\'t forget you\'ve disabled this - they\'ll be coming soon!">Hide average speed camera controls</span><br>';
  141. section.innerHTML += '<br>';
  142. var tbHackStr = '<sup>* If you have WME Toolbox installed, make sure the setting "Move zoom control to left" is ';
  143. if (document.body.dir != "rtl") {
  144. tbHackStr += 'OFF';
  145. } else {
  146. tbHackStr += 'ON';
  147. }
  148. tbHackStr += '.</sup><br>';
  149. section.innerHTML += tbHackStr;
  150. section.innerHTML += '<br>';
  151. section.innerHTML += '<b><a href="https://www.waze.com/forum/viewtopic.php?f=819&t=191178" title="Forum topic" target="_blank"><u>' +
  152. 'WME Fix UI</u></a></b> &nbsp; v' + wmefu_version;
  153.  
  154. addon.appendChild(section);
  155. addon.className = "tab-pane";
  156. return addon
  157. }
  158.  
  159. function addMyTab(model,modeID) {
  160. if (modeID === 0) {
  161. console.log("WMEFU: entering default mode, so creating tab");
  162. tabAttempts = 0;
  163. tabsLooper();
  164. } else {
  165. console.log("WMEFU: entering event mode, so not initialising");
  166. return;
  167. }
  168. }
  169.  
  170. function tabsLooper() {
  171. tabAttempts += 1;
  172. if (tabAttempts > 20) {
  173. // tried 20 times to create tab without luck
  174. console.log("WMEFU: Unable to create my tab after 20 attempts");
  175. return;
  176. }
  177. var userTabs = getId('user-info');
  178. var navTabs = getElementsByClassName('nav-tabs', userTabs)[0];
  179. if (typeof navTabs === "undefined") {
  180. //the basic tabs aren't there yet, so I can't add mine
  181. setTimeout(tabsLooper, 200);
  182. } else{
  183. var tabContent = getElementsByClassName('tab-content', userTabs)[0];
  184. newtab = document.createElement('li');
  185. newtab.innerHTML = '<a href="#sidepanel-FixUI" data-toggle="tab" title="Fix UI">FU</a>';
  186. navTabs.appendChild(newtab);
  187. tabContent.appendChild(wmeFUAddon);
  188. }
  189. }
  190.  
  191. function applyAllSettings() {
  192. moveZoomBar();
  193. shrinkBlackBar();
  194. hideUserInfo();
  195. compressSegmentTab();
  196. restyleReports();
  197. disableMapBlocker();
  198. narrowSidePanel();
  199. hideAveSpeedControls();
  200. }
  201.  
  202. function moveZoomBar() {
  203. var reportPanel = getId('panel-container');
  204. reportPanel.style.position = "absolute";
  205. if (_cbMoveZoomBar.checked) {
  206. addGlobalStyle('.olControlPanZoomBar { left: 10px; width: 30px; right: inherit; }');
  207. addGlobalStyle('#WMETB_ZoomLevelIndicator { left: 43px !important; right: inherit !important; }');
  208. if (document.body.dir != "rtl") {
  209. addGlobalStyle('.panel { left: 61px; }');
  210. } else {
  211. addGlobalStyle('.panel { right: inherit; }');
  212. }
  213. } else {
  214. addGlobalStyle('.olControlPanZoomBar { left: inherit; width: 30px; right: 10px; }');
  215. addGlobalStyle('#WMETB_ZoomLevelIndicator { left: inherit !important; right: 43px !important; }');
  216. if (document.body.dir != "rtl") {
  217. addGlobalStyle('.panel { left: inherit; }');
  218. } else {
  219. addGlobalStyle('.panel { right: 61px; }');
  220. }
  221. }
  222. }
  223.  
  224. function hideUserInfo() {
  225. // WME Panel Swap buttons - move them up if user info is hidden
  226. var PSButton1 = getId('WMEPS_UIButton');
  227. var PSButton2 = getId('WMEPS_EditButton');
  228. if (_cbHideUserInfo.checked) {
  229. addGlobalStyle('#sidebar #user-info #user-box { padding: 0px; }');
  230. addGlobalStyle('#sidebar #user-details .user-profile { display: none !important; }');
  231. if (PSButton1) PSButton1.style.top = '-27px';
  232. if (PSButton2) PSButton2.style.top = '-27px';
  233. // Keep My Layers toggle - move up if user info is hidden
  234. addGlobalStyle('.kml-toggle-container { top: -25px; }');
  235. } else {
  236. addGlobalStyle('#sidebar #user-info #user-box { padding: 20px; }');
  237. addGlobalStyle('#sidebar #user-details .user-profile { display: inherit !important; }');
  238. if (PSButton1) PSButton1.style.top = '0px';
  239. if (PSButton2) PSButton2.style.top = '0px';
  240. // Keep My Layers toggle - move back down if user info is shown
  241. addGlobalStyle('.kml-toggle-container { top: 13px; }');
  242. }
  243. }
  244.  
  245. function shrinkBlackBar() {
  246. var wm = getId('WazeMap');
  247. if (_cbShrinkBlackBar.checked) {
  248. addGlobalStyle('.topbar { height: 20px; line-height: 20px; }');
  249. addGlobalStyle('.topbar .location-info { font-size: 12px; }');
  250. } else {
  251. addGlobalStyle('.topbar { height: 30px; line-height: 30px; }');
  252. addGlobalStyle('.topbar .location-info { font-size: 15px; }');
  253. }
  254. // $(window).trigger('resize');
  255. window.dispatchEvent(new Event('resize'));
  256. }
  257.  
  258. function FALSEcompressSegmentTab() {
  259. _cbCompressSegmentTab.checked = _cbextraCBSection.checked;
  260. compressSegmentTab();
  261. }
  262.  
  263. function compressSegmentTab() {
  264. var ep=getId('edit-panel');
  265. if (_cbCompressSegmentTab.checked) {
  266. // shrink address
  267. addGlobalStyle('#edit-panel .primary-street { font-size: 14px; line-height: 15px; font-weight: 600; color: black; }');
  268. addGlobalStyle('#edit-panel .address-edit-view .preview .address-edit-btn:not(.disabled) { background-color: #FFF9C4; }');
  269. addGlobalStyle('#edit-panel .segment .address-edit-view, .edit-panel .segment .address-edit-view { margin-bottom: 5px; }');
  270. //shrink tabs
  271. addGlobalStyle('#sidebar .nav-tabs li a { padding: 4px; }');
  272. addGlobalStyle('#sidebar .nav-tabs { margin-bottom: 5px; }');
  273. //reduce some vertical margins
  274. addGlobalStyle('#edit-panel .contents { padding-top: 0px; }');
  275. addGlobalStyle('#edit-panel .form-group { margin-bottom: 2px; line-height: 1; font-size: 11px; }');
  276. addGlobalStyle('#edit-panel .selection { margin-bottom: 5px; }');
  277. addGlobalStyle('#sidebar .side-panel-section:not(:last-child) { margin-bottom: 2px; }');
  278. addGlobalStyle('#sidebar .side-panel-section:not(:last-child)::after { margin-top: 5px; margin-bottom: 2px; }');
  279. addGlobalStyle('#edit-panel .control-label { margin-bottom: 1px; }');
  280. addGlobalStyle('#sidebar .controls-container { padding-top: 2px; }');
  281. addGlobalStyle('#edit-panel .segment .speed-limit label { margin-bottom: 0px; }');
  282. addGlobalStyle('#edit-panel .more-actions { padding-top: 2px; }');
  283. addGlobalStyle('#edit-panel .segment .speed-limit .direction-label, #edit-panel .segment .speed-limit .unit-label { line-height: 2.1em; }');
  284. //shrink dropdown controls & buttons
  285. addGlobalStyle('#edit-panel button, #edit-panel select, #edit-panel .form-control { font-size: 11px; height: 22px; padding: 0px 4px; }');
  286. addGlobalStyle('#edit-panel .more-actions button:not(:last-of-type) { margin-bottom: 2px; }');
  287. addGlobalStyle('.edit-closure .input-group-addon { padding: 2px 8px; }');
  288. //fit road property checkboxes on one line for all three (if text length allows)
  289. addGlobalStyle('#edit-panel .controls-container { display: inline-block; }');
  290. addGlobalStyle('#edit-panel .controls-container label { font-size: 12px; line-height: 18px; padding-left: 22px; }');
  291. addGlobalStyle('#edit-panel .select-entire-street { width: 49%; overflow: hidden; }');
  292. addGlobalStyle('#edit-panel .edit-house-numbers { width: 49%; overflow: hidden; }');
  293. addGlobalStyle('#edit-panel .action-button { color: black; }');
  294. } else {
  295. //enlarge address
  296. addGlobalStyle('#edit-panel .primary-street { font-size: 18px; line-height: 24px; font-weight: inherit; color: inherit; }');
  297. addGlobalStyle('#edit-panel .address-edit-view .preview .address-edit-btn:not(.disabled) { background-color: inherit; }');
  298. addGlobalStyle('#edit-panel .segment .address-edit-view, .edit-panel .segment .address-edit-view { margin-bottom: 20px; }');
  299. //enlarge tabs
  300. addGlobalStyle('#sidebar .nav-tabs li a { padding: 5px 15px; }');
  301. addGlobalStyle('#sidebar .nav-tabs { margin-bottom: 20px; }');
  302. //restore vertical margins
  303. addGlobalStyle('#edit-panel .contents { padding-top: 20px; }');
  304. addGlobalStyle('#edit-panel .form-group { margin-bottom: 10px; line-height: 1.43; font-size: 13px; }');
  305. addGlobalStyle('#edit-panel .selection { margin-bottom: 20px; }');
  306. addGlobalStyle('#sidebar .side-panel-section:not(:last-child) { margin-bottom: 21px; }');
  307. addGlobalStyle('#sidebar .side-panel-section:not(:last-child)::after { margin-top: 21px; margin-bottom: 21px; }');
  308. addGlobalStyle('#edit-panel .control-label { margin-bottom: 5px; }');
  309. addGlobalStyle('#sidebar .controls-container { padding-top: 7px; }');
  310. addGlobalStyle('#edit-panel .segment .speed-limit label { margin-bottom: 5px; }');
  311. addGlobalStyle('#edit-panel .more-actions { padding-top: 10px; }');
  312. addGlobalStyle('#edit-panel .segment .speed-limit .direction-label, #edit-panel .segment .speed-limit .unit-label { line-height: 2.5em; }');
  313. //enlarge dropdown controls & buttons
  314. addGlobalStyle('#edit-panel button, #edit-panel select, #edit-panel .form-control { font-size: 13px; height: 32px; padding: 6px 12px; }');
  315. addGlobalStyle('#edit-panel .more-actions button:not(:last-of-type) { margin-bottom: 10px; }');
  316. addGlobalStyle('.edit-closure .input-group-addon { padding: 6px 8px; }');
  317. //restore road property checkboxes to one line per item
  318. addGlobalStyle('#edit-panel .controls-container { display: inherit; }');
  319. addGlobalStyle('#edit-panel .controls-container label { font-size: inherit; line-height: inherit; padding-left: 25px; }');
  320. addGlobalStyle('#edit-panel .select-entire-street { width: 100%; overflow: inherit; }');
  321. addGlobalStyle('#edit-panel .edit-house-numbers { width: 100%; overflow: inherit; }');
  322. addGlobalStyle('#edit-panel .action-button { color: inherit; }');
  323. }
  324. //tweak required for Speedhelper script
  325. addGlobalStyle('div[id^="spd_"] { line-height: 1.43; }');
  326. }
  327.  
  328. function restyleReports() {
  329. if (_cbRestyleReports.checked) {
  330. addGlobalStyle('#panel-container .panel { font-size: 12px; line-height: 15px; }');
  331. addGlobalStyle('#panel-container .problem-edit .header { padding: 5px 10px; line-height: 15px; }');
  332. addGlobalStyle('#panel-container .problem-edit .problem-data .title { line-height: 22px; }');
  333. addGlobalStyle('#panel-container .problem-edit .section .content { padding: 5px; }');
  334. addGlobalStyle('#WMEFP-UR-ALLPM { top: -2px !important; }');
  335. addGlobalStyle('#panel-container .problem-edit .conversation.section .comment .comment-content { padding: 5px; }');
  336. addGlobalStyle('#panel-container .problem-edit .conversation.section .new-comment-form { padding: 5px; }');
  337. addGlobalStyle('#panel-container .problem-edit .conversation.section .new-comment-form textarea { resize: vertical; height: 110px; margin-bottom: 5px; padding: 3px 5px; font-size: 12px; }');
  338. addGlobalStyle('#panel-container .btn { height: 20px; padding: 0px 10px;}');
  339. addGlobalStyle('#panel-container .problem-edit .actions .content { padding: 2px 5px;}');
  340. addGlobalStyle('#panel-container .problem-edit .actions .controls-container label { margin-bottom: 2px; }');
  341. addGlobalStyle('#panel-container .problem-edit .actions .navigation { margin-top: 5px;}');
  342. addGlobalStyle('#panel-container .problem-edit .actions .controls-container { display: inline-flex; flex-wrap: wrap; }');
  343. } else {
  344. addGlobalStyle('#panel-container .panel { font-size: inherit; line-height: inherit; }');
  345. addGlobalStyle('#panel-container .problem-edit .header { padding: 10px 15px; line-height: 21px; }');
  346. addGlobalStyle('#panel-container .problem-edit .problem-data .title { line-height: 40px; }');
  347. addGlobalStyle('#panel-container .problem-edit .section .content { padding: 15px; }');
  348. addGlobalStyle('#WMEFP-UR-ALLPM { top: 10px !important; }');
  349. addGlobalStyle('#panel-container .problem-edit .conversation.section .comment .comment-content { padding: 10px 15px 10px 15px; }');
  350. addGlobalStyle('#panel-container .problem-edit .conversation.section .new-comment-form { padding: 15px 15px 10px 15px; }');
  351. addGlobalStyle('#panel-container .problem-edit .conversation.section .new-comment-form textarea { resize: none; height: 70px; margin-bottom: 10px; padding: 6px 10px; font-size: 13px; }');
  352. addGlobalStyle('#panel-container .btn { height: inherit; padding: 6px 20px;}');
  353. addGlobalStyle('#panel-container .problem-edit .actions .content { padding: 15px;}');
  354. addGlobalStyle('#panel-container .problem-edit .actions .controls-container label { margin-bottom: 12px; }');
  355. addGlobalStyle('#panel-container .problem-edit .actions .navigation { margin-top: 10px;}');
  356. addGlobalStyle('#panel-container .problem-edit .actions .controls-container { display: inherit; flex-wrap: inherit; }');
  357. }
  358. }
  359.  
  360. function disableMapBlocker() {
  361. if (_cbDisableMapBlocker.checked) {
  362. addGlobalStyle('#popup-overlay { width: 0%; height: 0%; }');
  363. } else {
  364. addGlobalStyle('#popup-overlay { width: 100%; height: 100%; }');
  365. }
  366. }
  367.  
  368. function narrowSidePanel() {
  369. if (_cbNarrowSidePanel.checked) {
  370. addGlobalStyle('.row-fluid #sidebar { width: 250px; }');
  371. addGlobalStyle('.col-fixed-330 { width: 250px; }');
  372. if (document.body.dir != "rtl") {
  373. addGlobalStyle('.show-sidebar .row-fluid .fluid-fixed { margin-left: 250px; }');
  374. addGlobalStyle('.col-offset-330 { padding-left: 250px; }');
  375. } else {
  376. addGlobalStyle('.show-sidebar .row-fluid .fluid-fixed { margin-right: 250px; }');
  377. addGlobalStyle('.col-offset-330 { padding-right: 250px; }');
  378. }
  379. addGlobalStyle('.edit-closure .form { padding: 2px; }');
  380. addGlobalStyle('.edit-closure .date-input-group { width: 56%; }');
  381. } else {
  382. addGlobalStyle('.row-fluid #sidebar { width: 330px; }');
  383. addGlobalStyle('.col-fixed-330 { width: 330px; }');
  384. if (document.body.dir != "rtl") {
  385. addGlobalStyle('.show-sidebar .row-fluid .fluid-fixed { margin-left: 330px; }');
  386. addGlobalStyle('.col-offset-330 { padding-left: 330px; }');
  387. } else {
  388. addGlobalStyle('.show-sidebar .row-fluid .fluid-fixed { margin-right: 330px; }');
  389. addGlobalStyle('.col-offset-330 { padding-right: 330px; }');
  390. }
  391. addGlobalStyle('.edit-closure .form { padding 15px; }');
  392. addGlobalStyle('.edit-closure .date-input-group { width: 62%; }');
  393. }
  394. // $(window).trigger('resize')
  395. window.dispatchEvent(new Event('resize'));
  396. }
  397.  
  398. function hideAveSpeedControls() {
  399. if (_cbHideAveSpeedControls.checked) {
  400. addGlobalStyle('#segment-edit-general > .side-panel-section.attributes-form > .form-group:nth-of-type(4) { display: none; }');
  401. }else {
  402. addGlobalStyle('#segment-edit-general > .side-panel-section.attributes-form > .form-group:nth-of-type(4) { display: inherit; }');
  403. }
  404. }
  405.  
  406. //Helper functions
  407.  
  408. function addGlobalStyle(css) {
  409. var head, style;
  410. head = document.getElementsByTagName('head')[0];
  411. if (!head) {
  412. return;
  413. }
  414. style = document.createElement('style');
  415. style.type = 'text/css';
  416. style.innerHTML = css;
  417. head.appendChild(style);
  418. }
  419.  
  420. function getElementsByClassName(classname, node) {
  421. if(!node) node = document.getElementsByTagName("body")[0];
  422. var a = [];
  423. var re = new RegExp('\\b' + classname + '\\b');
  424. var els = node.getElementsByTagName("*");
  425. for (var i=0,j=els.length; i<j; i++)
  426. if (re.test(els[i].className)) a.push(els[i]);
  427. return a;
  428. }
  429.  
  430. function getId(node) {
  431. return document.getElementById(node);
  432. }
  433.  
  434. // Start it running
  435. setTimeout(init1, 2);
  436. })();