Forked from saitamanodoruji/drawr_home_illust_larger.user.js
Created
February 27, 2012 04:39
-
-
Save syoichi/1921446 to your computer and use it in GitHub Desktop.
継ぎ足した次のページでイラストのブックマーク(fav)をクリックした時、現在のページを開きなおしてしまう不具合を修正した。その他、スタイルの微修正、AutoPatchWorkへの対応などを行った。
This file contains hidden or 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== | |
// @id drawr home illust larger | |
// @name drawr home illust larger | |
// @namespace http://drawr.net/saitamanodoruji | |
// @author saitamanodoruji | |
// @version 0.0.4 | |
// @update 2012-02-27T13:45:55.783Z(GMT+09:00) | |
// @description britney spears | |
// @include http://drawr.net/home.php* | |
// @include http://drawr.net/new.php* | |
// @run-at document-end | |
// @priority 0 | |
// @compatibility Firefox 10.0.2(Scriptish 0.1.7, AutoPagerize 0.9.5), Chrome 17.0.963.56(AutoPagerize 0.3.4, AutoPatchWork 1.9.5), Safari 5.1.2(NinjaKit 0.8.5, AutoPagerize 0.3.3), Opera 11.61(AutoPatchWork 1.8.6) on Windows 7 Home Premium SP1 64bit | |
// @charset UTF-8 | |
// ==/UserScript== | |
/*jslint browser: true, maxerr: 50, maxlen: 80, indent: 4*/ | |
// Edition 2012-02-23 | |
(function executeIllustLarger(win, doc) { | |
'use strict'; | |
var pixiv, isHome, largeIllustOrAddBookmarkLink, favOnNextPage; | |
if (win.parent !== win) { | |
return; | |
} | |
pixiv = doc.getElementById('pixiv'); | |
isHome = location.pathname === '/home.php'; | |
if (!pixiv || (isHome && !doc.getElementsByClassName('homeBox').length)) { | |
return; | |
} | |
doc.head.appendChild(doc.createElement('style')).textContent = | |
isHome | |
? [ | |
'.homeBox {', | |
' margin-top: 20px;', | |
' padding: 7px;', | |
' width: auto;', | |
' height: auto;', | |
' background: #EFEFEF;', | |
'}', | |
'[id^="acttbl"] {', | |
' width: auto !important;', | |
' background-color: transparent !important;', | |
' display: block !important;', | |
'}' | |
].join('\n') | |
: [ | |
'#pixiv > .mgnTop10 {', | |
' margin-left: 3px;', | |
' padding: 20px;', | |
' background-color: white;', | |
'}', | |
'#pixiv > .mgnTop10 > div {', | |
' margin-top: 0 !important;', | |
' margin-left: 0 !important;', | |
' width: auto !important;', | |
'}', | |
'.drawr_box {', | |
' position: relative;', | |
' margin-right: 0 !important;', | |
' margin-bottom: 1px !important;', | |
' padding: 10px;', | |
' width: auto;', | |
' float: none;', | |
' background-image: url("../images/bg_entry.gif");', | |
'}', | |
'.drawr_info {', | |
' position: absolute;', | |
' top: 10px;', | |
' right: 10px;', | |
' width: 195px;', | |
' background-color: white;', | |
'}' | |
].join('\n'); | |
largeIllustOrAddBookmarkLink = function largeIllustOrAddBookmarkLink(arg) { | |
var target, nodes, nodesLen, node, illustLink; | |
target = arg.target || arg; | |
nodes = target.querySelectorAll( | |
'.homeBox table img, .drawr_box table img, .drawr_info' | |
); | |
nodesLen = nodes.length; | |
while (nodesLen) { | |
node = nodes[nodesLen -= 1]; | |
if (node.src) { | |
node.src = node.src.replace(/_\d+x\d+/, ''); | |
} else { | |
illustLink = node.previousElementSibling.querySelector('a'); | |
if (illustLink) { | |
node.insertAdjacentHTML('BeforeEnd', [ | |
'<a href="actfav.php' + illustLink.search + | |
'" name="actfav">', | |
'<img ', | |
'src="images/icon_bookmark_off.gif" ', | |
'alt="ブックマーク - ON/OFF" title="ブックマーク - ON/OFF', | |
'">', | |
'</a>' | |
].join('')); | |
} | |
} | |
} | |
}; | |
favOnNextPage = function favOnNextPage(evt) { | |
var star, favLink, xhr; | |
star = evt.target; | |
favLink = star.parentNode; | |
if (!(favLink.name === 'actfav' && !favLink.onclick)) { | |
return; | |
} | |
evt.preventDefault(); | |
xhr = new XMLHttpRequest(); | |
xhr.open('GET', favLink.href); | |
xhr.send(null); | |
star.src = | |
'images/icon_bookmark_' + | |
(/_on\./.test(star.src) ? 'off' : 'on') + | |
'.gif'; | |
}; | |
largeIllustOrAddBookmarkLink(doc); | |
pixiv.addEventListener('click', favOnNextPage); | |
doc.addEventListener( | |
'AutoPagerize_DOMNodeInserted', | |
largeIllustOrAddBookmarkLink | |
); | |
doc.addEventListener( | |
'AutoPatchWork.DOMNodeInserted', | |
largeIllustOrAddBookmarkLink | |
); | |
}(window, document)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment