BetterFark

I miss FarkAnalReverteresque and smiths

目前为 2016-03-27 提交的版本。查看 最新版本

// ==UserScript==
// @name         BetterFark
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  I miss FarkAnalReverteresque and smiths
// @author       LesserEvil
// @match        http://www.fark.com/*
// @match        http://fark.com/*
// @match        https://www.fark.com/*
// @match        https://fark.com/*
// @grant        none
// ==/UserScript==

'use strict';

function scrollIntoView(eleID) {
   var e = document.getElementById(eleID);
   if (!!e && e.scrollIntoView) {
       e.scrollIntoView();
   }
}

function appendElementToBody(elem)
{
    document.getElementsByTagName('body')[0].appendChild(elem);
}
function injectStyles(rule) {
    var elem = document.createElement("DIV");
    elem.innerHTML = '<style>' + rule + '</style>';
    appendElementToBody(elem);
}

function doRemoveBubbles()
{
    var commentIcons = document.getElementsByClassName("icon_comment");
    var i, bubbleCount=0;
    for( i in commentIcons )
    {
        if ( typeof(commentIcons[i]) == "object" )
        {
            if ( commentIcons[i].className != null )
            {
                bubbleCount++;
                commentIcons[i].className = "better_comment";
            }
            
        }
    }
    console.log("scrubbing "+bubbleCount+" bubbles away");
}

function displayFarkNew()
{
    scrollIntoView("new");
}

function doBetterFark()
{
    console.log("Making Fark a better place for you and me");
    var newsContainer = document.querySelectorAll('div#newsContainer')[0];
    var mainContainer = document.querySelectorAll('div#container')[0];
    if ( newsContainer !== null )
    {
        newsContainer.style.width = '100%';
    }
    else
    {
        console.log("Unable to find div.newsContainer");
    }
    if ( mainContainer !== null )
    {
        mainContainer.style.width = '100%';
    }
    else
    {
        console.log("Unable to find div.container");
    }
    
    injectStyles('a.icon_comment { border-width: 0px; }');
    injectStyles('a.better_comment { font-size: 120%; }');
    doRemoveBubbles();
    doRemoveBubbles();
    doRemoveBubbles();
    doRemoveBubbles();
    setTimeout(displayFarkNew(),100);
    setTimeout(doRemoveBubbles(), 100);
    setTimeout(doRemoveBubbles(), 200);
    setTimeout(doRemoveBubbles(), 3000);

}

setTimeout(doBetterFark(),100);