Dota 2 Lounge title notifications & autorefresh

(1) Dota 2 Lounge - My Trades

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Dota 2 Lounge title notifications & autorefresh
// @namespace   http://userscripts.org/users/WernieBert
// @description (1) Dota 2 Lounge - My Trades
// @include     http://dota2lounge.com*
// @version     1
// @grant       none
// ==/UserScript==

//***********************************************
// REFRESH DELAY (SECONDS)
// Change this variable to whatever refresh time you desire 

var refreshTime = 180;

//***********************************************

function ref()
{
    location.reload();
}

var nots = document.getElementsByClassName('notification');
var totalnots = 0;
for (var i = 0; i < nots.length; i++)
{
    var x = parseInt(nots[i].innerHTML);
    if (!isNaN(x) && nots[i].innerHTML.length < 5)
        totalnots += x;
}

if (totalnots == 0)
    var notificationText = '';
else
    var notificationText = '(' + totalnots.toString() + ')';

document.title = notificationText + ' ' + document.title;


//---------------------------------------
// Refreshing the page:
if (document.URL != 'http://dota2lounge.com/addtrade') // don't refresh the page if you are adding a trade because it will reset the trade that you were making
{
    window.setTimeout(ref,refreshTime * 1000);
    
    var divs = document.getElementsByTagName('div');
    var text=document.createElement("H3");
    var t=document.createTextNode('Refreshing page every ' + refreshTime.toString() + ' seconds.');
    text.appendChild(t);
    divs[5].appendChild(text);
}