Doublelist Filter Options

Add filter options to Doublelist listing pages

Verze ze dne 09. 03. 2019. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name     Doublelist Filter Options
// @description Add filter options to Doublelist listing pages
// @version  1
// @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.mt-4')[0]

  filterHTML = '<div class="container" id="filteroptions"><h2>Filters:</h2><br/><div><input name="pics" type="checkbox" id="pics" />&nbsp;<label for="pics">Require Picture</label></div>' +
    '<div><input name="minage" type="number" value="18" id="minage" />&nbsp;<label for="minage">Min Age</label></div>' +
    '<div><input name="maxage" type="number" value="99" id="maxage" />&nbsp;<label for="minage">Max Age</label></div>' + '</div>'

  mainContainer.innerHTML = filterHTML + mainContainer.innerHTML 

  var updatematches = function(){
    $('.postlinks2').hide()

    if($('#filteroptions #pics').is(":checked")){
      $('.postlinks2:has(.post_photo)').show()
    }else{
      $('.postlinks2').show()
    }

    posts = $('.postlinks2')

    minage = $('#filteroptions #minage').val()
    maxage = $('#filteroptions #maxage').val()

    posts.each(function(index){
      age = $(this).children('span').children('span')[1].innerText

      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()
  
})();