NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Camdevils.com tag and country search // @description Adds search for tags and countries on Camdevils.com. Uses fuse.js for fuzzy searching. Results are sorted by number of performers online right now. // @version 1.0.1 // @grant none // @license MIT // @copyright 2018, kompisn90 (https://openuserjs.org/users/kompisn90) // @include https://camdevils.com/tags/#* // @include https://camdevils.com/tags/ // @include https://camdevils.com/countries/ // @require https://cdnjs.cloudflare.com/ajax/libs/fuse.js/3.0.4/fuse.min.js // ==/UserScript== // ==OpenUserJS== // @author kompisn90 // ==/OpenUserJS== const tags = [...document.querySelectorAll('a')] .filter(a => a.href.match(/.*\/tags\/\w/) || a.href.match(/.*\/countries\/\w/)) .map(a => { return { name: a.textContent.split(' (')[0], link: a.href, count: parseInt((a.textContent.match(/.*\((\d+)\)/) || [0, 0])[1]) } }) .sort((a, b) => b.count - a.count) const options = { shouldSort: true, threshold: 0.3, location: 0, distance: 100, maxPatternLength: 32, minMatchCharLength: 1, keys: [ 'name' ] } const fuse = new Fuse(tags, options) const breadcrumbs = document.querySelector('.breadcrumb') const searchbox = document.createElement('input') const results = document.createElement('ul') searchbox.addEventListener('keyup', () => { while (results.firstChild) { results.removeChild(results.firstChild) } let result = fuse.search(searchbox.value) result = result .filter(tag => tag.count > 0) .sort((a, b) => b.count - a.count) .map(tag => { let item = document.createElement('li') let link = document.createElement('a') link.href = tag.link link.textContent = tag.name + ` (${tag.count})` item.appendChild(link) return item }) if (result.length === 0 && searchbox.value.length > 0) { result = document.createElement('li') result.className = 'alert-info' result.innerHTML = 'Nothing matched your search' result = [result] } result.forEach(listitem => results.appendChild(listitem)) }) breadcrumbs.parentNode.insertBefore(searchbox, breadcrumbs.nextSibling) breadcrumbs.parentNode.insertBefore(results, searchbox.nextSibling) searchbox.focus()