c-plusplus.net Alternating Post Backgrounds

try to take over the world!

09.08.2018 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         c-plusplus.net Alternating Post Backgrounds
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  try to take over the world!
// @author       Swordfishx86
// @include      https://www.c-plusplus.net/*
// @include      http://www.c-plusplus.net/*
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @grant        GM_addStyle
// ==/UserScript==

var background_colors = [ "#f2f2f2", "#f9f9f9" ];

function beautify(object, index)
{
    object.style.padding = "15px 10px 15px 10px"; // top right bottom left
    object.style.margin = "18px 0px 18px 0px";
    object.style.backgroundColor = background_colors[index % 2];
}

function posts_beautifier(selector, jNode) {
    var x = document.querySelectorAll("div.post-bar > hr");
    for (var i = 0; i < x.length; ++i) {
        x[i].style.display = "none";
    }

    x = document.querySelectorAll("blockquote");
    for (i = 0; i < x.length; ++i) {
        x[i].style.borderLeft = "5px solid #c9c9c9";
    }

    x = document.querySelectorAll(selector);
    for (i = 0; i < x.length; ++i) {
        beautify(x[i], i);
        var lines = x[i].querySelectorAll("hr");
        lines[lines.length - 1].style.display = "none";
    }
}

function generic_beautifier(selector, jNode)
{
    var x = document.querySelectorAll(selector);
    for (var i = 0; i < x.length; ++i) {
        beautify(x[i], i);
    }
}

function waitForKeyElements(selectorTxt, actionFunction, bWaitOnce, iframeSelector)
{
    var targetNodes, btargetsFound;

    if (typeof iframeSelector == "undefined") {
        targetNodes = $(selectorTxt);
    } else {
        targetNodes = $(iframeSelector).contents().find (selectorTxt);
    }

    if (targetNodes && targetNodes.length > 0) {
        btargetsFound = true;
        targetNodes.each ( function () {
            var jThis = $(this);
            var alreadyFound = jThis.data ('alreadyFound') || false;

            if (!alreadyFound) {
                var cancelFound = actionFunction (jThis);
                if (cancelFound) {
                    btargetsFound = false;
                } else {
                    jThis.data ('alreadyFound', true);
                }
            }
        } );
    }
    else {
        btargetsFound = false;
    }

    var controlObj = waitForKeyElements.controlObj || {};
    var controlKey = selectorTxt.replace (/[^\w]/g, "_");
    var timeControl = controlObj [controlKey];

    if (btargetsFound && bWaitOnce && timeControl) {
        clearInterval (timeControl);
        delete controlObj [controlKey]
    }
    else {
        if ( ! timeControl) {
            timeControl = setInterval(function(){waitForKeyElements(selectorTxt, actionFunction, bWaitOnce, iframeSelector);}, 300);
            controlObj [controlKey] = timeControl;
        }
    }
    waitForKeyElements.controlObj = controlObj;
}

var selectors = [
    "#content > div.row > div.topic.col-lg-12 > ul > li",
    "#content > div.row > div.category.col-lg-12 > ul > li",
    "#content > div.row > div.col-lg-12 > ul > li",
    "#content > div.row > div.category.col-lg-12 > div.subcategory > ul > li",
    "#content > div.recent > div.category > ul > li",
    "#content > div.popular > div.category > ul > li",
    "#content > div.unread > div.category > ul > li"
];

waitForKeyElements( selectors[0], posts_beautifier.bind(null, selectors[0]), false);
for(var i = 1; i < selectors.length; ++i) {
    waitForKeyElements (selectors[i], generic_beautifier.bind(null, selectors[i]), false);
}