Alwaysup script

Add quck filter feature to AlwaysUp

Tính đến 07-06-2018. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

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

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

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

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

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Alwaysup script
// @version      1.0.1
// @description  Add quck filter feature to AlwaysUp
// @author       Dmitry K
// @namespace    http://versonix.com
// @include     /^https?://.*?:8585/application.*$/
// @require      https://code.jquery.com/jquery-3.3.1.slim.min.js
// ==/UserScript==

(function() {
    'use strict';
    // add quicksort
    $('<td align=right><label>Quick Filter: <input type=text placeholder=Filter... list=quickFilterList id=quickFilter><button id=quickFilterReset>x</button><datalist id=quickFilterList></datalist></label></td>').appendTo($("body>p>table[border=1] table[cellpadding=4] tr"));
    const mainTable = $("body>p>table[border=1] table[cellpadding=6] tr:gt(0)");
    let dataList = $("#quickFilterList");
    $("#quickFilter")
    .val(localStorage.getItem("quickFilter"))
    .on('input', (e) => {
        localStorage.setItem("quickFilter", e.target.value);
        let filter = e.target.value.toLowerCase();
        mainTable.each(
            (i, e) => {
                let el = $(e);
                el.toggle(el.text().toLowerCase().indexOf(filter) >= 0);
            }
        )
    })
    .trigger("input").focus().select();
    $("#quickFilterReset").on("click", e => $("#quickFilter").val("").trigger("input"))
    let words = new Set(mainTable.text().split(/[\W+\s]+/).map(word=>word.toLowerCase()).filter(word => word.length>2 && /^[a-zA-Z]/.test(word)).sort()).forEach(word => dataList.append($('<option></option>').attr("value", word)));

})();