Created
February 24, 2012 12:30
-
-
Save saitamanodoruji/1900662 to your computer and use it in GitHub Desktop.
drawr home illust larger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name drawr home illust larger | |
// @namespace http://drawr.net/saitamanodoruji | |
// @description britney spears | |
// @include http://drawr.net/home.php* | |
// @include http://drawr.net/new.php* | |
// @version 0.0.4.20130125 | |
// @author saitamanodoruji | |
// ==/UserScript== | |
(function(){ | |
if (document.location.href.match(/^http:\/\/drawr\.net\/home\.php/)){ | |
GM_addStyle([ | |
'#content .floleft {', | |
'float: none;', | |
'}', | |
'.homeBox {', | |
'height: auto;', | |
'width: auto;', | |
'padding: 7px;', | |
'margin-top: 20px;', | |
'background: none;', | |
'background-color: #efefef;', | |
'}', | |
].join('')); | |
} else if (document.location.href.match(/^http:\/\/drawr\.net\/new\.php/)){ | |
GM_addStyle([ | |
'.mgnTop10 {', | |
'padding: 20px;', | |
'background: #FFF;', | |
'}', | |
'.mgnTop10 > div {', | |
'margin: 0 !important;', | |
'width: 865px !important;', | |
'}', | |
'.drawr_box {', | |
'width: 803px;', | |
'padding: 10px;', | |
'margin: 1px 0 0 !important;', | |
'background: url("../images/bg_entry.gif") repeat scroll 0 0 transparent;', | |
'}', | |
'.drawr_info {', | |
'width: 195px;', | |
'float: right;', | |
'background: none repeat scroll 0 0 #FFF;', | |
'}', | |
].join('')); | |
} | |
function modifyIllusts(node) { | |
if (document.location.href.match(/^http:\/\/drawr\.net\/home\.php/)){ | |
var illusts = document.evaluate( | |
'.//div[starts-with(@id, "act")][not(starts-with(@id, "acttbl"))]/table//img', | |
node, null, 7, null); | |
for (i=0; i<illusts.snapshotLength; i++) { | |
var illust = illusts.snapshotItem(i); | |
illust.src = illust.src.replace("_150x150.", "."); | |
//unsafeWindow.console.log(illust.src); | |
} | |
var acts = document.evaluate( | |
'.//div[starts-with(@id, "act")][not(starts-with(@id, "acttbl"))]', | |
node, null, 7, null); | |
for (i=0; i<acts.snapshotLength; i++) { | |
var act = acts.snapshotItem(i); | |
act.setAttribute("align", ""); | |
} | |
var acttbls = document.evaluate( | |
'.//div[starts-with(@id, "acttbl")]', | |
node, null, 7, null); | |
for (i=0; i<acttbls.snapshotLength; i++) { | |
var acttbl = acttbls.snapshotItem(i); | |
acttbl.style.display = "block"; | |
acttbl.style.backgroundColor = ""; | |
acttbl.style.textAlign = ""; | |
} | |
} else if (document.location.href.match(/^http:\/\/drawr\.net\/new\.php/)){ | |
var illusts = document.evaluate( | |
'.//div[contains(@class, "drawr_box")]//table//img', | |
node, null, 7, null); | |
for (i=0; i<illusts.snapshotLength; i++) { | |
var illust = illusts.snapshotItem(i); | |
illust.src = illust.src.replace("_150x150.", "."); | |
} | |
var divLefts = document.evaluate( | |
'.//div[contains(@class, "drawr_box")]/div[1]', | |
node, null, 7, null); | |
for (i=0; i<divLefts.snapshotLength; i++) { | |
var divLeft = divLefts.snapshotItem(i); | |
divLeft.style.cssFloat = 'left'; | |
var divClear = document.createElement('div'); | |
divClear.style.clear = 'both'; | |
divLeft.parentNode.appendChild(divClear); | |
// new.php から faved or not faved を確認する方法が無いので faved のも off.gif を表示 | |
// だから faved が出てもその操作は unfaved かも | |
var star = document.createElement('img'); | |
star.src = 'http://drawr.net/images/icon_bookmark_off.gif'; | |
var actfav = document.createElement('a'); | |
actfav.href = 'http://drawr.net/actfav.php?id=' + $X('.//a', divLeft)[0].href.match(/http:\/\/drawr\.net\/show\.php\?id=(\d+)/)[1]; | |
actfav.name = 'actfav'; | |
actfav.appendChild(star); | |
$X('./../div[contains(@class, "drawr_info")]', divLeft)[0].appendChild(actfav); | |
} | |
} | |
} | |
modifyIllusts(document); | |
document.body.addEventListener('AutoPagerize_DOMNodeInserted',function(evt){ | |
var node = evt.target; | |
var requestURL = evt.newValue; | |
var parentNode = evt.relatedNode; | |
modifyIllusts(node); | |
}, false); | |
// $X on XHTML | |
// @target Freifox3, Chrome3, Safari4, Opera10 | |
// @source http://gist.github.com/184276.txt | |
function $X (exp, context) { | |
context || (context = document); | |
var _document = context.ownerDocument || context, | |
documentElement = _document.documentElement, | |
isXHTML = documentElement.tagName !== 'HTML' && _document.createElement('p').tagName === 'p', | |
defaultPrefix = null; | |
if (isXHTML) { | |
defaultPrefix = '__default__'; | |
exp = addDefaultPrefix(exp, defaultPrefix); | |
} | |
function resolver (prefix) { | |
return context.lookupNamespaceURI(prefix === defaultPrefix ? null : prefix) || | |
documentElement.namespaceURI || ""; | |
} | |
var result = _document.evaluate(exp, context, resolver, XPathResult.ANY_TYPE, null); | |
switch (result.resultType) { | |
case XPathResult.STRING_TYPE : return result.stringValue; | |
case XPathResult.NUMBER_TYPE : return result.numberValue; | |
case XPathResult.BOOLEAN_TYPE: return result.booleanValue; | |
case XPathResult.UNORDERED_NODE_ITERATOR_TYPE: | |
// not ensure the order. | |
var ret = [], i = null; | |
while (i = result.iterateNext()) ret.push(i); | |
return ret; | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment