Last active
January 12, 2022 01:06
-
-
Save jxpsert/6b8b8c53c682b6cb1115c7d020f4dc15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name RPR Meldkamer GMS (jxpsert edit) | |
| // @namespace http://tampermonkey.net/ | |
| // @version 3.58 | |
| // @description Extra toevoegingen/Wijzigingen aan het GMS (jxpsert edit: aangeklikte suggestie gelijk verzenden, andere kleur knop) | |
| // @author Nick v Z. & jxpsert | |
| // @match https://intranet.roleplayreality.nl/gms/meldkamer.php | |
| // @match https://intranet.roleplayreality.nl/dashboard/gms/gms/meldkamer.php | |
| // @icon https://www.roleplayreality.nl/assets/images/favicon.png | |
| // @grant none | |
| // @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js | |
| // @require https://code.jquery.com/ui/1.13.0/jquery-ui.min.js | |
| // @updateUrl https://gist.github.com/jxpsert/6b8b8c53c682b6cb1115c7d020f4dc15/raw/4078b3e6a406ee32abd8c5341883b8d3e84bf4f1/rprgmsjxpsert.user.js | |
| // @downloadUrl https://gist.github.com/jxpsert/6b8b8c53c682b6cb1115c7d020f4dc15/raw/4078b3e6a406ee32abd8c5341883b8d3e84bf4f1/rprgmsjxpsert.user.js | |
| // ==/UserScript== | |
| var $ = window.jQuery; | |
| const endNavbar = document.querySelector('#navbarBasicExample > div > div > div'); | |
| $('#meldkamerdiv > nav > div.navbar-brand > a > h1').html('© <b>Meldkamer Systeem 2022</b> - Made By: Job, Joseph, <small>Nick & Jasper</small>'); | |
| // Maak de suggestie knop (rechtsboven in je beeld) | |
| const sugButton = document.createElement("button"); | |
| sugButton.classList.add('button'); | |
| sugButton.classList.add('is-primary'); | |
| sugButton.innerHTML = 'Suggesties'; | |
| sugButton.style.backgroundColor = '#00a7c4'; | |
| sugButton.style.fontWeight = 'bold'; | |
| sugButton.style.cursor = 'pointer'; | |
| sugButton.id = 'openSuggesties'; | |
| endNavbar.appendChild(sugButton); | |
| const sugBox = document.createElement('div'); | |
| sugBox.id = 'suggesties'; | |
| sugBox.style.width = '350px'; | |
| sugBox.style.height = '150px'; | |
| sugBox.style.position = 'absolute'; | |
| sugBox.style.zIndex = '3'; | |
| document.body.appendChild(sugBox); | |
| const moveBox = document.createElement('div'); | |
| moveBox.id = 'move'; | |
| moveBox.style.width = 'auto'; | |
| moveBox.style.borderBottomLeftRadius = '0'; | |
| moveBox.style.borderBottomRightRadius = '0'; | |
| moveBox.style.border = '0'; | |
| moveBox.style.padding = '5px'; | |
| moveBox.style.backgroundColor = '#222F3E'; | |
| moveBox.style.color = 'white'; | |
| moveBox.style.fontWeight = 'bold'; | |
| moveBox.style.borderTopRightRadius = '15px'; | |
| moveBox.style.borderTopLeftRadius = '15px'; | |
| moveBox.style.cursor = 'drag'; | |
| moveBox.style.fontFamily = 'Arial, Helvetica, sans-serif'; | |
| moveBox.style.borderBottom = '2px solid white'; | |
| moveBox.style.fontSize = '14px'; | |
| moveBox.style.textAlign = 'center'; | |
| moveBox.innerHTML = 'Karakteristieken'; | |
| sugBox.appendChild(moveBox); | |
| const minButton = document.createElement('button'); | |
| minButton.style.float = 'right'; | |
| minButton.style.borderRadius = '50%'; | |
| minButton.style.backgroundColor = '#1E272D'; | |
| minButton.style.color = '#1E272D'; | |
| minButton.style.marginRight = '10px'; | |
| minButton.style.border = '0'; | |
| minButton.style.fontSize = '15px'; | |
| minButton.style.position = 'absolute'; | |
| minButton.style.right = '5px'; | |
| minButton.style.top = '8px'; | |
| minButton.style.width = '15px'; | |
| minButton.style.height = '15px'; | |
| minButton.style.cursor = 'pointer'; | |
| minButton.innerHTML = ' '; | |
| minButton.id = 'miniButton'; | |
| moveBox.appendChild(minButton); | |
| const itemL = document.createElement('div'); | |
| itemL.style.backgroundColor = '#775C67'; | |
| itemL.style.border = '3px solid darkslategrey'; | |
| itemL.style.cursor = 'pointer'; | |
| itemL.style.overflowY = 'auto'; | |
| itemL.style.maxHeight = '280px'; | |
| itemL.style.border = '0'; | |
| itemL.id = 'item'; | |
| sugBox.appendChild(itemL); | |
| const searchBar = document.createElement('input'); | |
| searchBar.style.border = '0'; | |
| searchBar.style.margin = '0'; | |
| searchBar.style.border = '0'; | |
| searchBar.style.backgroundColor = '#AC8E9A'; | |
| searchBar.style.width = '100%'; | |
| searchBar.style.fontSize = '14px'; | |
| searchBar.style.fontWeight = 'bold'; | |
| searchBar.style.padding = '6px'; | |
| searchBar.style.position = 'sticky'; | |
| searchBar.style.top = '0'; | |
| searchBar.type = 'text'; | |
| searchBar.placeholder = 'Zoeken...'; | |
| searchBar.id = 'zoekList'; | |
| itemL.appendChild(searchBar); | |
| const diList = document.createElement('ul'); | |
| diList.style.listStyleType = 'none'; | |
| diList.style.width = '100%'; | |
| diList.style.padding = '0'; | |
| diList.style.margin = '0'; | |
| diList.style.textAlign = 'center'; | |
| diList.style.fontFamily = 'Arial, Helvetica, sans-serif'; | |
| diList.id = 'suggestieList'; | |
| itemL.appendChild(diList); | |
| const closeBtn = document.createElement('button'); | |
| closeBtn.style.width = '100%'; | |
| closeBtn.style.borderBottomLeftRadius = '15px'; | |
| closeBtn.style.borderBottomRightRadius = '15px'; | |
| closeBtn.style.border = '0'; | |
| closeBtn.style.padding = '5px'; | |
| closeBtn.style.backgroundColor = '#222F3E'; | |
| closeBtn.style.color = 'white'; | |
| closeBtn.style.fontWeight = 'bold'; | |
| closeBtn.style.borderTopRightRadius = '0'; | |
| closeBtn.style.borderTopLeftRadius = '0'; | |
| closeBtn.style.cursor = 'pointer'; | |
| closeBtn.style.fontFamily = 'Arial, Helvetica, sans-serif'; | |
| closeBtn.style.fontSize = '14px'; | |
| closeBtn.id = 'sluitSuggesties'; | |
| closeBtn.innerHTML = 'Sluiten'; | |
| sugBox.appendChild(closeBtn); | |
| const css = document.createElement('style'); | |
| css.innerHTML = '.suggestieItem:nth-child(even) { background-color: #AC8E9A; } .suggestieItem { padding: 6px; font-size: 12px; color: black; font-weight: bold; } ::placeholder { color: rgba(0, 0, 0, 0.6); } .suggestieItem:hover { background-color: red; color: white; } '; | |
| document.head.appendChild(css); | |
| $('#suggesties').hide(); | |
| $.ajax({ | |
| type: 'POST', | |
| url: 'https://nickvz.nl/rprgms.php', | |
| dataType: 'text', | |
| data: $("#infoForm").serialize() | |
| }).done(function (results) { | |
| let items = results.split('`'); | |
| for (let i = 0; i < items.length - 1; i++) { | |
| $('#suggestieList').append('<li class="suggestieItem" onclick="let sendInput = document.getElementById(`kladblok_sendmsg`); sendInput.value = this.innerHTML; sendInput.focus();" oncontextmenu="let sendInput = document.getElementById(`kladblok_sendmsg`); sendInput.value = this.innerHTML; sendInput.focus(); sendInput.dispatchEvent(new KeyboardEvent(`keydown`,{keyCode:13})); return false;">' + items[i] + '</li>'); | |
| } | |
| }); | |
| if (localStorage.getItem('boxX') && localStorage.getItem('boxY')) { | |
| let leftIndex = localStorage.getItem('boxX'); | |
| let topIndex = localStorage.getItem('boxY'); | |
| let boxStatus = localStorage.getItem('boxStatus'); | |
| $('#suggesties').css('left', leftIndex + 'px'); | |
| $('#suggesties').css('top', topIndex + 'px'); | |
| if (boxStatus == "true") { | |
| $('#item').show(); | |
| } else if (boxStatus == "false") { | |
| $('#item').hide(); | |
| } | |
| console.log('Loading Coords..'); | |
| } else { | |
| $('#suggesties').css('left', '50px'); | |
| $('#suggesties').css('top', '50px'); | |
| console.log('Standard Coords..'); | |
| } | |
| function checkVisibility() { | |
| let window = $('#suggesties').is(':visible'); | |
| if (window) { | |
| $('#openSuggesties').attr('disabled', true); | |
| } else { | |
| $('#openSuggesties').attr('disabled', false); | |
| } | |
| } | |
| setInterval(checkVisibility, 2500); | |
| $('#kladblok_sendmsg').on('focus', function () { | |
| $('#suggesties').show("slow"); | |
| }); | |
| $('#openSuggesties').on('click', function () { | |
| $('#suggesties').show("slow"); | |
| }); | |
| $('#sluitSuggesties').on('click', function () { | |
| $('#suggesties').hide(); | |
| checkVisibility(); | |
| }); | |
| $('#kladblok_sendmsg').on('input', function () { | |
| let filter = $(this).val().split(' ').pop(); | |
| $("ul li").each(function () { | |
| if ($(this).text().search(new RegExp(filter, "i")) < 0) { | |
| $(this).hide(); | |
| } else { | |
| $(this).show() | |
| } | |
| }); | |
| }); | |
| $('#zoekList').on('input', function () { | |
| let filter = $(this).val().split(' ').pop(); | |
| $("ul li").each(function () { | |
| if ($(this).text().search(new RegExp(filter, "i")) < 0) { | |
| $(this).hide(); | |
| } else { | |
| $(this).show() | |
| } | |
| }); | |
| }); | |
| $("#suggesties").draggable({ | |
| handle: "div#move", | |
| containment: "html", | |
| stop: function () { | |
| updateBoxCoords(); | |
| } | |
| }); | |
| $('#kladblok_sendmsg').on('keypress', function (e) { | |
| if (e.keyCode == 13) { | |
| $('ul li').show(); | |
| $('#zoekList').val(''); | |
| } | |
| }); | |
| $('#miniButton').on('click', function () { | |
| $('#item').toggle('slow'); | |
| setTimeout(updateBoxCoords, 800); | |
| }); | |
| function updateBoxCoords() { | |
| let mainCoord = $('#suggesties').offset(); | |
| let x = mainCoord.left; | |
| let y = mainCoord.top; | |
| let s = $('#item').is(':visible'); | |
| localStorage.clear(); | |
| localStorage.setItem('boxX', x); | |
| localStorage.setItem('boxY', y); | |
| localStorage.setItem('boxStatus', s); | |
| console.log('Box-Coords Updated'); | |
| console.log('Optielist is: ' + s); | |
| } | |
| $('#suggesties').css('cursor', 'move'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment