Doublelist Filter Options

Add filter options to Doublelist listing pages

当前为 2019-03-09 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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