Created
July 22, 2011 02:31
-
-
Save kk6/1098767 to your computer and use it in GitHub Desktop.
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 MyPixiv | |
// @namespace http://d.hatena.ne.jp/kk6/ | |
// @description とりあえずお知らせがうざかったので。 | |
// @include http://www.pixiv.net/* | |
// @require https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js | |
// ==/UserScript== | |
(function ($) { | |
// News at main contents | |
var newstop = $("div.NewsTop"); | |
var c_news_h = newstop.children("h1"); | |
var c_news_b = newstop.children("ul"); | |
// News at right sidebar | |
var r_news_h = $("div.area_rightSpace"); | |
var r_news_b = $("ul.area_rightNews"); | |
var cnews = {'head':c_news_h, 'body': c_news_b}; | |
var rnews = {'head':r_news_h, 'body': r_news_b}; | |
var news = [cnews, rnews]; | |
function contents_toggle (dict) { | |
dict.body.css({ 'display' : 'none' }); | |
dict.head.toggle( | |
function () { | |
dict.body.css({'display' : 'block' }); | |
}, | |
function () { | |
dict.body.css({'display' : 'none' }); | |
} | |
); | |
}; | |
for (var i=0; i<news.length; i++) { | |
contents_toggle(news[i]); | |
}; | |
})(unsafeWindow.jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pixivのお知らせが邪魔だったので…ただしたまには見るのでトグルできるようにした。
jQuery はPixivのほうで読み込んでたのでそっちを使い回してます。
jQuery UI は使うかもしれないってだけでrequireだけしといて未使用。なんか色々してみたいなー。
あと、17~19行目もっとスマートにならないかな。