// ==UserScript== // @name Stash Performer URL Searchbox // @namespace https://github.com/7dJx1qP/stash-userscripts // @description Adds a search by performer url textbox to the performers page // @version 0.2.0 // @author 7dJx1qP // @match http://localhost:9999/* // @grant unsafeWindow // @require https://raw.githubusercontent.com/7dJx1qP/stash-userscripts/master/src\StashUserscriptLibrary.js // ==/UserScript== (function () { 'use strict'; const { stash, Stash, waitForElementId, waitForElementClass, waitForElementByXpath, getElementByXpath, } = unsafeWindow.stash; stash.addEventListener('page:performers', function () { waitForElementClass("btn-toolbar", function () { if (!document.getElementById('performer-url-search-input')) { const toolbar = document.querySelector(".btn-toolbar"); const newGroup = document.createElement('div'); newGroup.classList.add('mx-2', 'mb-2', 'd-flex'); toolbar.appendChild(newGroup); const perfUrlGroup = document.createElement('div'); perfUrlGroup.classList.add('flex-grow-1', 'query-text-field-group'); newGroup.appendChild(perfUrlGroup); const perfUrlTextbox = document.createElement('input'); perfUrlTextbox.setAttribute('id', 'performer-url-search-input'); perfUrlTextbox.classList.add('query-text-field', 'bg-secondary', 'text-white', 'border-secondary', 'form-control'); perfUrlTextbox.setAttribute('placeholder', 'URL…'); perfUrlTextbox.addEventListener('change', () => { const url = `${window.location.origin}/performers?c={"type":"url","value":"${perfUrlTextbox.value}","modifier":"EQUALS"}` window.location = url; }); perfUrlGroup.appendChild(perfUrlTextbox); } }); }); })();