WME OH Scripts

Recommended scripts for editing in Ohio

目前为 2016-10-06 提交的版本。查看 最新版本

// ==UserScript==
// @name         WME OH Scripts
// @namespace    https://gf.qytechs.cn/users/30701-justins83-waze
// @version      0.1.2
// @description  Recommended scripts for editing in Ohio
// @include      https://www.waze.com/editor/*
// @include      https://www.waze.com/*/editor/*
// @include      https://beta.waze.com/*
// @author       JustinS83
// @grant        none
// @require      https://gf.qytechs.cn/scripts/9794-wlib/code/wLib.js?version=106259
// @require      https://gf.qytechs.cn/scripts/23614-wlibext/code/wLibExt.js?version=150020
// @license      GPLv3
// ==/UserScript==

/* global W */
/* global wLib */

(function() {
    'use strict';

    // Your code here...
    function bootstrap(tries) {
        tries = tries || 1;

        if (window.W &&
            window.W.map &&
            window.W.model) {
            init();
        } else if (tries < 1000) {
            setTimeout(function () {bootstrap(tries++);}, 200);
        }
    }

    bootstrap();

    function init(){
        var section = document.createElement('div');
        section.style.padding = "8px 16px";
        section.id = "OHScriptsSettings";
        section.innerHTML  = '<div title="OHScriptTitle">Toggling options requires a hard refresh.</div>'
            + '<p><div title="OHValidatorLocalization" class="controls-container"><input type="checkbox" id="_cbOHValidatorLocalizationEnable" /><label for="_cbOHValidatorLocalizationEnable">OH Validator Localization</label></div>'
            +  '<div title="OH Counties 2014" class="controls-container"><input type="checkbox" id="_cbOHCounties2014Enable" /><label for ="_cbOHCounties2014Enable"> OH Counties 2014</label></div>'
            +  '<div title="OH Cities 2014-1" class="controls-container"><input type="checkbox" id="_cbOHCities20141Enable" /><label for ="_cbOHCities20141Enable"> OH Cities 2014-1</label></div>'
            +  '<div title="OH Cities 2014-2" class="controls-container"><input type="checkbox" id="_cbOHCities20142Enable" /><label for ="_cbOHCities20142Enable"> OH Cities 2014-2</label></div>'
            +'</p>';

        new wLib.Interface.Tab('OH Scripts', section.innerHTML);

        if(localStorage.OHScripts){
            console.log("OH Scripts exists!");
            var options = JSON.parse(localStorage.OHScripts);
            $('#_cbOHValidatorLocalizationEnable').attr('checked', options[1]);
            $('#_cbOHCounties2014Enable').attr('checked', options[2]);
            $('#_cbOHCities20141Enable').attr('checked', options[3]);
            $('#_cbOHCities20142Enable').attr('checked', options[4]);
        }
        else{
            $('#_cbOHValidatorLocalizationEnable').attr('checked', true);
            $('#_cbOHCounties2014Enable').attr('checked', true);
            $('#_cbOHCities20141Enable').attr('checked', false);
            $('#_cbOHCities20142Enable').attr('checked', false);
        }

        /*
        $('#_cbOHValidatorLocalizationEnable').attr('checked', myOptions.get('OHValidatorLocalization'));
        $('#_cbOHCounties2014Enable').attr('checked', myOptions.get('OHCounties'));
        $('#_cbOHCities20141Enable').attr('checked', myOptions.get('OHCities1'));
        $('#_cbOHCities20142Enable').attr('checked', myOptions.get('OHCities2'));*/

        $('#_cbOHValidatorLocalizationEnable').change(function(){
            SaveSettings();
        });
        $('#_cbOHCounties2014Enable').change(function(){
            SaveSettings();
        });
        $('#_cbOHCities20141Enable').change(function(){
            SaveSettings();
        });
        $('#_cbOHCities20142Enable').change(function(){
            SaveSettings();
        });

        if($('#_cbOHValidatorLocalizationEnable').is(':checked'))
            $.getScript("https://gf.qytechs.cn/scripts/11240-wme-counties-ohio-census-2014/code/WME%20Counties%20Ohio%20Census%202014.user.js");

        if($('#_cbOHCounties2014Enable').is(':checked'))
            $.getScript("https://gf.qytechs.cn/scripts/8746-wme-validator-localization-for-ohio/code/WME%20Validator%20Localization%20for%20Ohio.user.js");

        if($('#_cbOHCities20141Enable').is(':checked'))
            $.getScript("https://gf.qytechs.cn/scripts/17391-wme-ohio-cities-census-2014-1/code/WME%20Ohio%20Cities%20Census%202014%20-%201.user.js");

        if($('#_cbOHCities20142Enable').is(':checked'))
            $.getScript("https://gf.qytechs.cn/scripts/17392-wme-ohio-cities-census-2014-2/code/WME%20Ohio%20Cities%20Census%202014%20-%202.user.js");

    }

    function SaveSettings(){
        if (localStorage) {
			var options = [];
			// preserve previous options which may get lost after logout
			if (localStorage.OHScripts) { options = JSON.parse(localStorage.OHScripts); }
			options[1] = $('#_cbOHValidatorLocalizationEnable').is(':checked');
			options[2] = $('#_cbOHCounties2014Enable').is(':checked');
			options[3] = $('#_cbOHCities20141Enable').is(':checked');
			options[4] = $('#_cbOHCities20142Enable').is(':checked');
			localStorage.OHScripts = JSON.stringify(options);
		}
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址