Skip to content

Instantly share code, notes, and snippets.

@Cougar
Created October 6, 2012 17:09
Show Gist options
  • Save Cougar/3845496 to your computer and use it in GitHub Desktop.
Save Cougar/3845496 to your computer and use it in GitHub Desktop.
WME black map background toggle
// ==UserScript==
// @name Change WME background to black
// @namespace http://version6.net/
// @description Add radio button to change background color
// @include https://world.waze.com/editor/*
// @include https://world.waze.com/map-editor/*
// @version 0.0.1
// ==/UserScript==
//-----------------------------------------------------------------------------------------------------------------------------------------
// all code between here and the next ------------- marker line provided by timbones to replace the unsafeWindow workaround
if ('undefined' == typeof __RTLM_PAGE_SCOPE_RUN__)
{
(
function page_scope_runner()
{
// If we're _not_ already running in the page, grab the full source
// of this script.
var my_src = "(" + page_scope_runner.caller.toString() + ")();";
// Create a script node holding this script, plus a marker that lets us
// know we are running in the page scope (not the Greasemonkey sandbox).
// Note that we are intentionally *not* scope-wrapping here.
var script = document.createElement('script');
script.setAttribute("type", "text/javascript");
script.textContent = "var __RTLM_PAGE_SCOPE_RUN__ = true;\n" + my_src;
// Insert the script node into the page, so it will run, and immediately
// remove it to clean up. Use setTimeout to force execution "outside" of
// the user script scope completely.
setTimeout(function(){document.body.appendChild(script);document.body.removeChild(script);}, 0);
}
)();
// Stop running, because we know Greasemonkey actually runs us in
// an anonymous wrapper.
return;
}
//-----------------------------------------------------------------------------------------------------------------------------------------
function changeColorScheme() {
var blackColorScheme = document.getElementById('_cbBlackColorSCheme').checked;
wm = document.getElementById('WazeMap');
if (blackColorScheme) {
wm.style.backgroundColor = "black";
} else {
wm.style.backgroundColor = "white";
}
}
// Greate color shceme button div and add it to the end of map-footer
var csDiv = document.createElement('div');
csDiv.setAttribute('id','ColorScheme');
csDiv.innerHTML = 'Black Color Scheme <input type="checkbox" id="_cbBlackColorSCheme" />';
document.getElementById('map-footer').appendChild(csDiv);
// setup onclick handler for instant update
document.getElementById('_cbBlackColorSCheme').onclick = changeColorScheme;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment