Skip to content

Instantly share code, notes, and snippets.

@tily
Created June 22, 2009 01:19
Show Gist options
  • Save tily/133752 to your computer and use it in GitHub Desktop.
Save tily/133752 to your computer and use it in GitHub Desktop.
make zozo search better
// ==UserScript==
// @name make ZOZO search better
// @namespace http://d.hatena.ne.jp/tily/
// @include http://zozo.jp/_search/*
// ==/UserScript==
(function(){
// apply to document
modify_items(document)
// add style
GM_addStyle(<><![CDATA[
div.ZR_home-searccolumn-searchlist-box {
float: none !important;
width: 505px !important;
height: 700px !important;
background-image : none !important;
}
div.image {
width: 500px !important;
height: 604px !important;
}
div.row, div.shop, div.price {
width: 500px !important;
text-align: right !important;
}
div.bottomicon {
display: none;
}
]]></>)
// register to AutoPagerize
if(typeof AutoPagerize != 'undefined') {
AutoPagerize.addDocumentFilter(modify_items)
}
// modify items
function modify_items(cxt) {
var items = $x('.//div[@class="ZR_home-searccolumn-searchlist-box"]', cxt)
items.forEach(function(item) {
// disable onmouseover and onmouseout
$x('./@onmouseover', item)[0].nodeValue = null
$x('./@onmouseout', item)[0].nodeValue = null
image_div = $x('./div[@class="image"]', item)[0]
// get link and disable onclick
onclick = $x('./@onclick', image_div)[0]
var link = onclick.value.match(/location.href='(.*?)';/)[1]
onclick.nodeValue = null
// add link to image
var a = document.createElement('a')
a.href = link
var img = image_div.childNodes[1]
img.src = img.src.replace(/\?w=125&h=150/, '?w=500&h=600')
a.appendChild(img)
image_div.insertBefore(a, image_div.firstChild)
})
}
// xpath function
function $x(xpath, node) {
var node = node || document
var doc = node.ownerDocument ? node.ownerDocument : node
var nodesSnapshot = doc.evaluate(xpath, node, null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
var data = []
for (var i = 0; i < nodesSnapshot.snapshotLength; i++) {
data.push(nodesSnapshot.snapshotItem(i))
}
return data
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment