NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @namespace https://openuser.js.org/users/udo80 // @name rtpass-update // @description Improvement for the passwords app to search the folder tree // @copyright 2018, Udo Woitek (https://openuserjs.org/users/udo80) // @license Apache-2.0 // @version 1.0.1 // @include http://passwords.* // @grant none // @updateURL https://openuserjs.org/meta/udo80/rtpass-update.meta.js // @run-at document-idle // ==/UserScript== // ==OpenUserJs== // @author Udo Woitek <udo.woitek@raytion.com> // ==/OpenUserJs== !function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);var r=function(){function e(){}return e.getRootElement=function(){for(var e=document.getElementsByTagName("b"),t=0;t<e.length;++t)if("Root"===e[t].innerText)return e.item(t).closest("td")},e.prototype.injectControls=function(e){if(e){var t=document.createElement("div");t.style.margin="1em",this.inputElement=this.createInputField(),this.applyEventListeners(),t.appendChild(this.inputElement),e.insertBefore(t,e.firstChild)}},e.prototype.applyEventListeners=function(){var e=this;if(!this.inputElement)throw new Error("Initialization error.");this.inputElement.addEventListener("keyup",function(t){if(13===t.keyCode){e.clearMarks();var n=e.inputElement.value;e.searchFor(n),t.stopPropagation()}})},e.prototype.searchFor=function(e){var t=this,n=document.querySelectorAll("a[href^='index.jsp?folderid=']");n&&Array.from(n).forEach(function(n,r){t.markFolderEntryIfFound(n,e)})},e.prototype.markFolderEntryIfFound=function(e,t){e.text&&e.text.toLowerCase().search(t.toLowerCase())>-1&&(null!==e.querySelector("b")?this.markSectionEntry(e,t):(this.markFolderEntry(e,e.innerText,t),this.changeFolderEntryVisibility(e,"block")))},e.prototype.clearMarks=function(){var e=this;Array.from(document.getElementsByClassName("found-entry")).forEach(function(t){var n=t;e.changeFolderEntryVisibility(n,"none"),t.parentElement.replaceChild(document.createTextNode(n.innerText),t)})},e.prototype.markSectionEntry=function(e,t){var n=e.firstChild;this.markFolderEntry(n,n.innerText,t)},e.prototype.markFolderEntry=function(e,t,n){var r=t.toLowerCase().search(n.toLowerCase()),o=n.length,i=t.substr(0,r),a=t.substr(r,o),l=t.substr(r+o),c=document.createElement("span");c.classList.add("found-entry"),c.style.color="red",c.innerText=a;var s=document.createTextNode(i),u=document.createTextNode(l);e.innerHTML="",e.appendChild(s),e.appendChild(c),e.appendChild(u)},e.prototype.changeFolderEntryVisibility=function(e,t){for(var n=e;n&&!(n instanceof HTMLDivElement);)n=n.parentElement;n&&(n.style.display=t)},e.prototype.getChildren=function(e){for(var t=[].slice.call(e.children),n=0;t.length>n;)t=t.concat([].slice.call(t[n].children)),n++;return t},e.prototype.createInputField=function(){var e=document.createElement("input");return e.type="text",e.placeholder="Enter search string",e},e}();(new r).injectControls(r.getRootElement())}]);