Wikidot: Traffic Table

A recent addition to Wikidot sites is the ability to check/monitor traffic bandwidth. This comes as Wikidot announced it will be providing a new type of sites — Community Sites, benefiting popular community-driven sites providing them with assistance when needed.

Along with it came the news that Wikidot might start applying traffic usage restrictions depending on your Wikidot plan.

Quote from michal frackowiak
Another thing is that we are planning to add bandwidth and likely usage limits to Free, Pro Lite, Pro and Pro Plus accounts. Although the limits are far above what an average site generates, some sites will definitely cross that line.

And now, Wikidot has now introduced "traffic usage" statistics will help allow users to monitor their site's bandwidth usage.

The only issue is, there is no way to check these traffic stats from a table. It's currently all muddled in the midst of the sites list here: But I've written a little script to solve this. My quick Javascript hack will extract all the traffic information and sorts and displays all the sites you're master admin — ranking the highest traffic first.

From 5a4a21b954791245f7f480d57ce78e2e to… 79695f690339121c76d05ed12837150f

The Code

Just copy and paste the following code to the browser's address bar when you're on the page.

(Update #2: This is revision 2, fixed bug with Firefox)

javascript:if(!document.location.href.match(/sites/)){ alert("Must run at, click OK to redirect"); window.location.href="";  }else{usageStruct = [];function tobytes(a){if(a.match(/ kB$/)){b = parseFloat(a.replace(/ kB$/,""))*1000;}else if(a.match(/ MB$/)){b = parseFloat(a.replace(/ MB$/,""))*1000*1000;}else if(a.match(/ GB$/)){b = parseFloat(a.replace(/ GB$/,""))*1000*1000*1000;}else if(a.match(/ TB$/)){b = parseFloat(a.replace(/ TB$/,""))*1000*1000*1000*1000;}else{b = parseFloat(a.replace(/ Bytes$/,""));}return b;}$j(".site-traffic .show").each(function(){usageStruct.push({"site":$j.trim($j(this).parent().parent().parent().find(".url").text()),"usage":tobytes($j.trim($j(this).text())),"usagestr":$j.trim($j(this).text())});});usageStruct.sort(function(a,b) { return parseFloat(b.usage) - parseFloat(a.usage) } );usageList = "<table class=\"wiki-content-table\"><tbody><tr><th>Site</th><th>Usage</th></tr>"; $j.each(usageStruct,function(i,v){usageList += "<tr><td>" + "</td><td>" + v.usagestr +"</td></tr>";});usageList += "</tbody></table>";$j("#page-content").html(usageList);}

Using the code with Firefox (update #3)

There are some browsers that do not allow javascript code to be executed from the address bar (in the context of the document). So, the only way to get around that is to:

  • Run the code in the Web Console (Ctrl + Shift + K)
    • Firefox > Web Developer > Web Console (Ctrl + Shift + K)
  • Save the code as a bookmarklet:

comments powered by Disqus

Old Comments

Add a New Comment
or Sign in as Wikidot user
(will not be published)
- +

Add a New Comment

Unless otherwise stated, all of the site's contents (including articles, blog post and code snippets) is:
Copyright © Kenneth Tsang 2014