// ==UserScript== // @name KG - enhance search forms // @description countrypicker for main search, requests search // @namespace KG // @include http*://*karagarga.in/* // @exclude http*://*karagarga.in/adsearch.php* // @exclude http*://forum.karagarga.in/* // @grant none // @version 1.3 // @downloadURL https://update.greasyfork.icu/scripts/800/KG%20-%20enhance%20search%20forms.user.js // @updateURL https://update.greasyfork.icu/scripts/800/KG%20-%20enhance%20search%20forms.meta.js // ==/UserScript== // don't run in iframes if (!window.frameElement) { // alter the search form that's on all pages var searchForm = document.forms.namedItem("searchform"); var country = document.createElement('select'); country.setAttribute("name", "country"); searchForm.insertBefore(country, searchForm.firstChild); var countryCode = ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' ; country.innerHTML = countryCode; // requests page search - page code has errors so easiest to just add a new form if (window.location.href.indexOf('/viewrequests.php') != -1) { var newForm = document.createElement('div'); newForm.innerHTML = 'New search form:


'; var target = document.querySelector("a.req"); target.parentNode.insertBefore(newForm, target); var c2 = document.createElement('select'); var newForm = document.getElementById("newForm"); c2.setAttribute("name", "country"); c2.innerHTML = countryCode; newForm.insertBefore(c2, newForm.firstChild); } // make link to new requests sort by added if (window.location.href.indexOf('/all_requests.php') != -1) { var links = document.links; for (i=0; i < links.length; i++) { if (links[i].href.indexOf('viewrequests.php') != -1) { links[i].href += "?sort=added"; } } } } // end iframe check