Source for "eBay Hacks - Show only negative feedback Mod"

By thorbenhauer
Has 43 other scripts.


// eBay Hacks - Show only negative feedback MOD user script
// version 0.5.1
// 2008-04-11
// Copyright 2006-2008, thorbenhauer
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
// -----------------------------------------------------------------------------
//
// Based on eBay Hacks - Show only negative feedback user script
// Script location: http://userscripts.org/scripts/show/696
//
// -----------------------------------------------------------------------------
//
// With Contributions by Lucas Malor (http://userscripts.org/users/27940)
// and Mithrandir (http://userscripts.org/users/5587)
// Thanks!
//
// -----------------------------------------------------------------------------
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//
// -----------------------------------------------------------------------------
//
// ==UserScript==
// @name          eBay Hacks - Show only negative feedback Mod
// @namespace     http://userscripts.org/users/9022
// @description   http://userscripts.org/scripts/show/5060
// @include       http://feedback*.ebay.tld/ws/eBayISAPI.dll?*
//                for Opera (which doesn't understand tld):
// @include       http://feedback.ebay.com.au/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.at/ws/eBayISAPI.dll?*
// @include       http://feedback.befr.ebay.be/ws/eBayISAPI.dll?*
// @include       http://feedback.benl.ebay.be/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.ca/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.fr/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.de/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.com.hk/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.in/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.ie/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.it/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.com.my/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.nl/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.ph/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.pl/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.com.sg/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.es/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.ch/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.co.uk/ws/eBayISAPI.dll?*
// @include       http://feedback.ebay.com/ws/eBayISAPI.dll?*
// ==/UserScript==
//
// -----------------------------------------------------------------------------
(function () { // function wrapper for Opera

/*
 Configure site
 
 Possible values:
 - "toolhaus"
   Show only the negative and neutral comments via toolhaus.org.
 - "ebay"
   Show only the negative comments for the last 365 days via internal eBay
   function.
*/
var site = "toolhaus";

/*
 Configure view (only relevant when site = "toolhaus")
 
 Possible values:
 - true
   Loads toolhaus.org in an iframe.
 - false
   Create regular links to toolhaus.org
*/
var iFramed = true;

var userid, anchor, rcvdURL, rcvdString, rcvdTitle, leftURL, leftString,
    leftTitle;
var tld = document.domain.split(".ebay.")[1];
var be = "";
if (tld == "be") {
    be = "." + document.domain.split(".ebay.")[0].split(".")[1];
}
switch (site) {
    case "ebay":
        rcvdURL = "http://feedback" + be + ".ebay." + tld +
            "/ws/eBayISAPI.dll?ViewFeedback2&ftab=AllFeedback&" +
            "items=200&interval=365&which=negative&userid=";
        break;
    case "toolhaus":
        rcvdURL = "http://toolhaus.org/cgi-bin/negs?Dirn=Received+by&User=";
        leftURL = "http://toolhaus.org/cgi-bin/negs?Dirn=Left+by&User=";
        break;
    default:
        rcvdURL = "http://toolhaus.org/cgi-bin/negs?Dirn=Received+by&User=";
        leftURL = "http://toolhaus.org/cgi-bin/negs?Dirn=Left+by&User=";
        break; 
}
switch (tld) {
    case "de":
    case "at":
    case "ch":
        if (site == "toolhaus") {
            rcvdURL =
                "http://toolhaus.org/cgi-bin/negs-de?Dirn=Erhaltene&User=";
            leftURL =
                "http://toolhaus.org/cgi-bin/negs-de?Dirn=Abgegebene&User=";
        }
        rcvdString = "Erh. Beschw.";
        rcvdTitle = "Erhaltene Beschwerden";
        leftString = "Abg. Beschw.";
        leftTitle = "Abgegebene Beschwerden";
        break;
    case "com":
    case "com.au":
    case "ca":
    case "in":
    case "ie":
    case "com.my":
    case "ph":
    case "com.sg":
    case "co.uk":
        rcvdString = "Comp. rec.";
        rcvdTitle = "Complaints received";
        leftString = "Comp. left";
        leftTitle = "Complaints left";
        break;
    case "it":
        rcvdString = "Neg. ricevuti";
        rcvdTitle = "Neg. ricevuti";
        leftString = "Neg. dati";
        leftTitle = "Neg. dati";
        break;
    default:
        rcvdString = "Comp. rec.";
        rcvdTitle = "Complaints received";
        leftString = "Comp. left";
        leftTitle = "Complaints left";
        break;
}

anchor = document.evaluate("//ul[@class = 'navtabs']", document, null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null).snapshotItem(0);
if (anchor == null) {
    anchor = document.evaluate("//table[contains(@class, " +
        "'pageTab-pageLevels')]/tbody/tr", document, null,
        XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null).snapshotItem(0);
    userid = document.evaluate("//li[@class='pdm-item']/" +
        "a[contains(@href, 'myworld.')]/@href", document, null,
        XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
        null).snapshotItem(0).value.split("/")[3];
    var td = document.createElement("td");    
    td.setAttribute("class", "pageTab-dummy");
    anchor.appendChild(td);
    td.setAttribute("style", "padding-right: 3px");
    td = document.createElement("td");
    td.setAttribute("class", "pageTab-inactiveLft");
    td.id = "FeedbackTabs_tab_lft_5";
    anchor.appendChild(td);
    td = document.createElement("td");
    td.setAttribute("class", "pageTab-inactiveRgt");
    td.id = "FeedbackTabs_tab_rgt_5";
    td.innerHTML = '<div class="pageTab-padd"><a id="rcvd" title="' + rcvdTitle + '" href="' + rcvdURL +
        userid + '">' + rcvdString + '</a></div>';
    anchor.appendChild(td);
    if (site == "toolhaus" && iFramed) {
        td.addEventListener("click", framing, false);
        var div, rcvdIframe, leftIframe, bckp, parent, active;
        bckp = document.evaluate("//table[@class='FbOuterYukon']",
            document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
            null).snapshotItem(0);
        parent = bckp.parentNode;
        div = document.createElement("div");
        parent.replaceChild(div, bckp);
        div.appendChild(bckp);
        active = document.evaluate("//td[@class='pageTab-activeRgt']",
            document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
            null).snapshotItem(0);
        var a = active.getElementsByTagName("a")[0];
        a.setAttribute("id", "bckp");
        a.addEventListener("click", framing, false);
    }
    if (site != "ebay") {
        td = document.createElement("td");
        td.setAttribute("class", "pageTab-dummy");
        anchor.appendChild(td);
        td.setAttribute("style", "padding-right: 3px");
        td = document.createElement("td");
        td.setAttribute("class", "pageTab-inactiveLft");
        td.id = "FeedbackTabs_tab_lft_6";
        anchor.appendChild(td);
        td = document.createElement("td");
        td.setAttribute("class", "pageTab-inactiveRgt");
        td.id = "FeedbackTabs_tab_rgt_6";
        td.innerHTML = '<div class="pageTab-padd"><a id="left" title="' + leftTitle + '" href="' +
            leftURL + userid + '">' + leftString + '</a></div>';
        if (site == "toolhaus" && iFramed) {
            td.getElementsByTagName("a")[0].addEventListener("click",
                framing, false);
        }
        anchor.appendChild(td);
    }
    anchor = document.getElementsByTagName("head")[0];
    var style = document.createElement("style");
    style.innerHTML = "td.pageTab-inactiveRgt * {font-size: x-small " +
        "!important;} td.pageTab-activeRgt * {font-size: x-small !important;}";
    anchor.appendChild(style);
    return;
}
userid = document.evaluate("//input[@name='userid']/@value", document, null,
    XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotItem(0).value;
var li = document.createElement("li");
li.innerHTML = '<a id="rcvd" title="' + rcvdTitle + '" href="' + rcvdURL +
    userid + '">' + rcvdString + '</a>';
if (site == "toolhaus" && iFramed) {
    li.addEventListener("click", framing, false);
    var div, rcvdIframe, leftIframe, bckp, parent, active;
    bckp = document.evaluate("//div[@class='navTabContainer']/" +
        "following-sibling::div", document, null,
        XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotItem(0);
    parent = bckp.parentNode;
    div = document.createElement("div");
    parent.replaceChild(div, bckp);
    div.appendChild(bckp);
    active = document.evaluate("//ul[@class='navtabs']/li[@class='active']",
        document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
        null).snapshotItem(0);
    var a = active.getElementsByTagName("a")[0];
    a.setAttribute("id", "bckp");
    a.addEventListener("click", framing, false);
}
anchor.appendChild(li);
if (site != "ebay") {
    li = document.createElement("li");
    li.innerHTML = '<a id="left" title="' + leftTitle + '" href="' + leftURL +
        userid + '">' + leftString + '</a>';
    if (site == "toolhaus" && iFramed) {
        li.addEventListener("click", framing, false);
    }
    anchor.appendChild(li);
}
anchor = document.getElementsByTagName("head")[0];
var style = document.createElement("style");
style.innerHTML = "ul.navtabs li {font-size: x-small}";
anchor.appendChild(style);

function framing(event) {
    event.preventDefault();
    switch (event.target.id) {
        case "rcvd":
            bckp.style.display = "none";
            if (leftIframe != null) {
                leftIframe.style.display = "none";
            }
            if (rcvdIframe == null) {
                rcvdIframe = createIframe("rcvd", userid);
                div.appendChild(rcvdIframe);
            }
            rcvdIframe.style.display = "";
            break;
        case "left":
            bckp.style.display = "none";
            if (rcvdIframe != null) {
                rcvdIframe.style.display = "none";
            }
            if (leftIframe == null) {
                leftIframe = createIframe("left", userid);
                div.appendChild(leftIframe);
            }
            leftIframe.style.display = "";
            break;
        case "bckp":
            if (rcvdIframe != null) {
                rcvdIframe.style.display = "none";
            }
            if (leftIframe != null) {
                leftIframe.style.display = "none";
            }
            bckp.style.display = "";
            break;
    }
    var parent = event.target.parentNode.parentNode; 
    if (parent.nodeName == "TD") {
        active.setAttribute("class", "pageTab-inactiveRgt");
        active.previousSibling.setAttribute("class", "pageTab-inactiveLft");
        parent.setAttribute("class", "pageTab-activeRgt");
        parent.previousSibling.setAttribute("class", "pageTab-activeLft");
        active = parent;
    } else {
        active.setAttribute("class", "");
        parent.setAttribute("class", "active");
        active = parent;
    }
}

function createIframe(mode, uid) {
    var iframe = document.createElement("iframe");
    switch (mode) {
        case "rcvd":
            iframe.setAttribute("src", rcvdURL + userid);
            break;
        case "left":
            iframe.setAttribute("src", leftURL + userid);
            break;
    }
    iframe.setAttribute("style", "background-color: white; " +
        "width: 99.6%; height: 860px;");
    return iframe;
}

})(); // function wrapper for Opera