From 4b5d343b308d466be79ae2c888d89ec69c3a21eb Mon Sep 17 00:00:00 2001 From: insane210 Date: Sun, 17 May 2015 00:54:08 +0200 Subject: [PATCH] Update and rename custom-ui.user.js to hide-ui.user.js --- plugins/custom-ui.user.js | 132 ----------------------------- plugins/hide-ui.user.js | 172 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+), 132 deletions(-) delete mode 100644 plugins/custom-ui.user.js create mode 100644 plugins/hide-ui.user.js diff --git a/plugins/custom-ui.user.js b/plugins/custom-ui.user.js deleted file mode 100644 index a6ea81a3d..000000000 --- a/plugins/custom-ui.user.js +++ /dev/null @@ -1,132 +0,0 @@ -// ==UserScript== -// @id iitc-plugin-custom-ui@insane210 -// @name IITC plugin: Custom UI -// @category Misc -// @version 0.1.0.@@DATETIMEVERSION@@ -// @namespace https://github.com/jonatkins/ingress-intel-total-conversion -// @updateURL @@UPDATEURL@@ -// @downloadURL @@DOWNLOADURL@@ -// @description [@@BUILDNAME@@-@@BUILDDATE@@] Hide user interface elements -// @include https://www.ingress.com/intel* -// @include http://www.ingress.com/intel* -// @match https://www.ingress.com/intel* -// @match http://www.ingress.com/intel* -// @grant none -// ==/UserScript== - -@@PLUGINSTART@@ - -// PLUGIN START //////////////////////////////////////////////////////// - -// use own namespace for plugin -window.plugin.customUI = function() {}; - -window.plugin.customUI.ScreenshotMode = false; - -window.plugin.customUI.loadSettings = function () { - if (localStorage.getItem('customUI') === null) { - var options = { - // id: [enabled, 'name'], - chatcontrols: [true, 'Chattabs'], - chat: [true, 'Chat'], - chatinput: [true, 'Chatinput'], - sidebar: [true, 'Sidebar'], - updatestatus: [true, 'Statusbar'], - bookmarks: [true, 'Bookmarks'], - portal_highlight_select: [true, 'Portal highlighter'], - drawtools: [true, 'Drawtools'], - mouse: [true, 'Mouse pointer'], - }; - - localStorage.setItem('customUI', options); - }; - - window.plugin.customUI.options = localStorage.getItem('customUI'); -}; - -window.plugin.customUI.resetSettings = function () { - localStorage.removeItem('customUI'); - - window.plugin.customUI.loadSettings(); -}; - -window.plugin.customUI.toggleScreenshotMode = function () { - if (window.plugin.customUI.ScreenshotMode) { - $('#chatcontrols').toggle(); - $('#chat').toggle(); - $('#chatinput').toggle(); - $('#sidebartoggle').toggle(); - $('#scrollwrapper').toggle(); - $('#updatestatus').toggle(); - $('#bkmrksTrigger').toggle(); - $('#bookmarksBox').toggle(); - $('#portal_highlight_select').toggle(); - $('.leaflet-control-container').toggle(); - - $('*').css({'cursor': ''}); - - window.plugin.customUI.ScreenshotMode = false; - } else { - $('#chatcontrols').toggle(); - $('#chat').toggle(); - $('#chatinput').toggle(); - $('#sidebartoggle').toggle(); - $('#scrollwrapper').toggle(); - $('#updatestatus').toggle(); - $('#bkmrksTrigger').toggle(); - $('#bookmarksBox').toggle(); - $('#portal_highlight_select').toggle(); - $('.leaflet-control-container').toggle(); - - $('*').css({'cursor': 'none'}); - - window.plugin.customUI.ScreenshotMode = true; - } -}; - -window.plugin.customUI.showOptions = function() { - - var html = 'Reset Settings' + - '
' + - '' + - '' + - '' + - ''; - // + 'Copy Drawn Items' - // + 'Paste Drawn Items' - // + (window.requestFile != undefined - // ? 'Import Drawn Items' : '') - // + ((typeof android !== 'undefined' && android && android.saveFile) - // ? 'Export Drawn Items' : '') - // + 'Reset Drawn Items' - // + 'Snap to portals'; - - dialog({ - html: html, - id: 'plugin-customUI-options', - dialogClass: 'ui-dialog', - title: 'Custom UI Options' - }); -}; - -var setup = function() { - $('head').append(''); - - window.plugin.customUI.loadSettings(); - - document.addEventListener('keydown', function(e) { - // pressed alt+h - if (e.keyCode == 72 && !e.shiftKey && !e.ctrlKey && e.altKey && !e.metaKey) { - window.plugin.customUI.toggleScreenshotMode(); - } - }, false); - $('#toolbox').append(' Custom UI Opt'); -}; - -// PLUGIN END ////////////////////////////////////////////////////////// - -@@PLUGINEND@@ diff --git a/plugins/hide-ui.user.js b/plugins/hide-ui.user.js new file mode 100644 index 000000000..ae647d12e --- /dev/null +++ b/plugins/hide-ui.user.js @@ -0,0 +1,172 @@ +// ==UserScript== +// @id iitc-plugin-hide-ui@insane210 +// @name IITC plugin: Hide UI +// @category Misc +// @version 0.1.0.@@DATETIMEVERSION@@ +// @namespace https://github.com/jonatkins/ingress-intel-total-conversion +// @updateURL @@UPDATEURL@@ +// @downloadURL @@DOWNLOADURL@@ +// @description [@@BUILDNAME@@-@@BUILDDATE@@] Hide user interface elements +// @include https://www.ingress.com/intel* +// @include http://www.ingress.com/intel* +// @match https://www.ingress.com/intel* +// @match http://www.ingress.com/intel* +// @grant none +// ==/UserScript== + +@@PLUGINSTART@@ + +// PLUGIN START //////////////////////////////////////////////////////// + +// use own namespace for plugin +window.plugin.hideUI = function() {}; + +// store current state of screenshot mode +window.plugin.hideUI.ScreenshotMode = false; + + +// write settings to local storage +window.plugin.hideUI.saveSettings = function () { + localStorage.setItem('hideUI', JSON.stringify(window.plugin.hideUI.options)); +}; + + +// load settings from local storage +window.plugin.hideUI.loadSettings = function () { + // if settings not available, create new object with default values + if (localStorage.getItem('hideUI') === null) { + var options = { + // id: [boolean enabled, string name], + chatwrapper: [true, 'Chat'], + sidebarwrapper: [true, 'Sidebar'], + updatestatus: [true, 'Statusbar'], + bookmarksBox: [true, 'Bookmarks Box'], + portal_highlight_select: [true, 'Portal highlighter'], + drawtools: [true, 'Drawtools'], + }; + + localStorage.setItem('hideUI', JSON.stringify(options)); + }; + + window.plugin.hideUI.options = JSON.parse(localStorage.getItem('hideUI')); +}; + + +// reset settings back to default values +window.plugin.hideUI.resetSettings = function () { + localStorage.removeItem('hideUI'); + + window.plugin.hideUI.loadSettings(); +}; + + +// hide or show UI elements depending on settings +window.plugin.hideUI.applySettings = function () { + for (var key in window.plugin.hideUI.options) { + if (window.plugin.hideUI.options.hasOwnProperty(key)) { + var option = window.plugin.hideUI.options[key]; + + if (option.hasOwnProperty('0')){ + if (option[0] === true) { + $('#'+key).show(); + } else { + $('#'+key).hide(); + }; + } + } + } +}; + + +// switch screenshot mode on or off +window.plugin.hideUI.toggleScreenshotMode = function () { + if (window.plugin.hideUI.ScreenshotMode) { + $('#chatwrapper').show(); + $('#sidebarwrapper').show(); + $('#updatestatus').show(); + $('#bkmrksTrigger').show(); + $('#bookmarksBox').show(); + $('#portal_highlight_select').show(); + $('#leaflet-control-container').show(); + + $('*').css({'cursor': ''}); + + window.plugin.hideUI.ScreenshotMode = false; + } else { + $('#chatwrapper').hide(); + $('#sidebarwrapper').hide(); + $('#updatestatus').hide(); + $('#bkmrksTrigger').hide(); + $('#bookmarksBox').hide(); + $('#portal_highlight_select').hide(); + $('#leaflet-control-container').hide(); + + $('*').css({'cursor': 'none'}); + + window.plugin.hideUI.ScreenshotMode = true; + } +}; + + +window.plugin.hideUI.showOptions = function() { + + var html = 'Reset Settings' + + '
' + + '
Always hide:
'; + + for (var key in window.plugin.hideUI.options) { + if (window.plugin.hideUI.options.hasOwnProperty(key)) { + var option = window.plugin.hideUI.options[key]; + + if (option.hasOwnProperty('0')){ + html += '