Greasy Fork

Greasy Fork is available in English.

Trademe Auction listing Full Breadcrumb

Display Full Category Path in TM Listings

当前为 2015-06-14 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name Trademe Auction listing Full Breadcrumb
// @namespace http://None.com
// @include http://www.trademe.co.nz/*auction-*
// @include http://www.trademe.co.nz/*Listing.aspx*
// @grant none
// @version 1.22
 
/*
>> Description:

TM Make plenty of pointless changes to their site.
Previously when you are viewing an action listing, the path to the category the auction
is listed in is displayed as a link form just above the auction title.

EX.:  Home > Computers > Desktops > No monitor

clicking any part of the link would have taken you to the associated category directory.

With the new change, if you click on an auction link from within a members listing pages, the
catagory links from that auction listing will only display auctions from that
particular member not all members as it used to do.

EX:  membername > Computers > Desktops > No monitor

This stupid change has annoyed me long enough to create this greasemonkey script.


This script will not run on following categories as they are not effected by this change
(1) Trade Me Jobs
(2) Trade Me Property
(3) Trade Me Property
(4) Movies-TV

*/
 
// @description Display Full Category Path in TM Listings
// ==/UserScript==

// There are two selectable options available this script can perform:

// 1 - create another link below the member only breadcrumb which will list auctions from all members.
// 2 - replace the member-only breadcrumb with the full path breadcrumb.

//   Edit the line below these instructions to set if you prefer one or two  breadcrumbs displayed
//   set the number in the line below to either 1 or 2. 
//   e.g "var NoOfBreadCrumbs = 1" to diplay one breadbrumb or "var NoOfBreadCrumbs = 2" for both breadcrumbs.
//   ensure the line below remains EXACT as described above including sentence case and spaces.

var NoOfBreadCrumbs = 1

var i; 
var code = document.documentElement.innerHTML;

bc = window.TradeMe.BreadCrumbs;                   // get breadcrumbs value 
var temp1 = code.indexOf('<a href="/">Home</a>');  // Check if page already has full root catagory path
var temp2 = bc.indexOf('Trade Me Jobs');           // Check if listing is in Jobs
var temp3 = bc.indexOf('Trade Me Motors');         // Check if listing is in Motors
var temp4 = bc.indexOf('Trade Me Property');       // Check if listing is in Property

if (temp1 < 0 && temp2 < 0  && temp3 < 0 && temp4 < 0) {
    var pathU = bc.split("|");                       // pathU = breadcrumbs split by pipe   
    var bc = bc.toLowerCase();                       // Convert breadcrumbs to lowercase for use in url path
    var pathL = bc.split("|");                       // pathL = breadcrumbs split by pipe           
    
    for (i = 0; i < pathL.length; i++) {
        pathL[i] = pathL[i].replace(" &amp; ", "-");   // Replace Amperstand`s with a dash
        pathL[i] = pathL[i].replace(", ", "-");        // Replace comma with a dash
        pathL[i] = pathL[i].replace(" ", "-");         // Replace space with a dash
    }

   var codeInsert = '<a href="/">Home</a>&nbsp;&gt;\n\n';
   codeInsert += '<a href="/' + pathL[0] + '">' + pathU[0] + '</a>&nbsp;&gt;\n\n';

    if (pathL.length > 1) {
        codeInsert += '<a href="/' + pathL[0] + '/' + pathL[1] + '">' + pathU[1] + '</a>&nbsp;&gt;\n\n';
    }
    if (pathL.length > 2) {
        codeInsert += '<a href="/' + pathL[0] + '/' + pathL[1] + '/' + pathL[2] + '">' + pathU[2] + '</a>&nbsp;&gt;\n\n';
    }
    if (pathL.length > 3) {
       codeInsert += '<a href="/' + pathL[0] + '/' + pathL[1] + '/' + pathL[2] + '/' + pathL[3]  + '">' + pathU[3] + '</a>&nbsp;&gt;\n\n';
    }

    codeInsert = codeInsert.substring(0, codeInsert.length - 7);    // Remove the greater than symbol from the last catagory
    codeInsert += '</p>' 
    
    if (NoOfBreadCrumbs == 1)
    {
    document.getElementById("BreadcrumbsContainer").innerHTML = codeInsert;
    }

    if (NoOfBreadCrumbs == 2)
    {
    document.getElementById("BreadcrumbsContainer").innerHTML += codeInsert;
    }
}