StackExchange chat links

Adds a chat link to the left hand nav of the home page of all Stack sites followed by a lightly filtered list of recently active chat rooms

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name StackExchange chat links
// @namespace http://ostermiller.org/
// @version 1.00
// @description Adds a chat link to the left hand nav of the home page of all Stack sites followed by a lightly filtered list of recently active chat rooms
// @include /https?\:\/\/([a-z\.]*\.)?(stackexchange|askubuntu|superuser|serverfault|stackoverflow|answers\.onstartups)\.com\/$/
// @exclude *://chat.stackoverflow.com/*
// @exclude *://chat.stackexchange.com/*
// @exclude *://chat.*.stackexchange.com/*
// @exclude *://api.*.stackexchange.com/*
// @exclude *://data.stackexchange.com/*
// @connect chat.stackoverflow.com
// @connect chat.stackexchange.com
// @connect chat.meta.stackexchange.com
// @grant GM_xmlhttpRequest
// ==/UserScript==
(function() {
    'use strict';
    var base='https://chat.stackexchange.com/'
    var nav = $('.left-sidebar .nav-links .nav-links')
    var chatlink=$('<li>').html('<a class="pl8 js-gps-track nav-links--link" href="'+base+'?tab=site&sort=active&host='+location.hostname+'">Chat</a>')
    nav.append(chatlink)
    var chatlinks=$('<ol class="nav-links">')
    chatlink.append(chatlinks)
    GM_xmlhttpRequest({
        method: "GET",
        url: base+'?tab=site&sort=active&host='+location.hostname,
        responseType: 'html',
        onload:function (resp) {
            $(resp.responseText).find('.roomcard').each(function(){
                var name=$(this).find('.room-name').html().replace('"/', '"'+base)
                if (!name.match(/((discussion between)|(room for).* and )|(discussion on answer|question)/i)){
                    var act=$(this).find('.last-activity').html().replace('"/', '"'+base)
                    var daysago = act.match(/([0-9])+d ago/)
                    if (!daysago || parseInt(daysago) <= 7) chatlinks.append($('<li>').html(name + " " + act))
                }
            });
        }
    });
})();