Add filter options to Doublelist listing pages
当前为
// ==UserScript==
// @name Doublelist Filter Options
// @description Add filter options to Doublelist listing pages
// @version 2
// @grant GM.getValue
// @grant GM.setValue
// @include http://doublelist.com/city/*/*
// @include https://doublelist.com/city/*/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @run-at document-idle
// @namespace https://greasyfork.org/users/257342
// ==/UserScript==
(async () => {
mainContainer = $('.container')[0]
filterHTML = '<div class="container" id="filteroptions"><h2>Filters:</h2><br/><div><input name="pics" type="checkbox" id="pics" /> <label for="pics">Require Picture</label></div>' +
'<div><input name="minage" type="number" value="18" id="minage" /> <label for="minage">Min Age</label></div>' +
'<div><input name="maxage" type="number" value="99" id="maxage" /> <label for="minage">Max Age</label></div>' + '</div>'
mainContainer.innerHTML = filterHTML + mainContainer.innerHTML
var updatematches = function(){
$('.list').hide()
if($('#filteroptions #pics').is(":checked")){
$('.list:has(.orn)').show()
}else{
$('.list').show()
}
posts = $('.list')
minage = $('#filteroptions #minage').val()
maxage = $('#filteroptions #maxage').val()
posts.each(function(index){
if($(this).children('a').children('span').length > 2)
age = $(this).children('a').children('span')[2].innerText
else
age = -1
if(age < minage || age > maxage)
$(this).hide()
})
GM.setValue("minage", minage)
GM.setValue("maxage", maxage)
GM.setValue("pics", $('#filteroptions #pics').is(":checked"))
}
$('#filteroptions #pics').prop('checked', await GM.getValue("pics", false))
$('#filteroptions #minage').val(await GM.getValue("minage", 18))
$('#filteroptions #maxage').val(await GM.getValue("maxage", 99))
$('#filteroptions #pics').change(updatematches)
$('#filteroptions #minage').change(updatematches)
$('#filteroptions #maxage').change(updatematches)
updatematches()
})();