Skip to content

Instantly share code, notes, and snippets.

@yesmeck
Created January 10, 2012 05:28
Show Gist options
  • Save yesmeck/1587203 to your computer and use it in GitHub Desktop.
Save yesmeck/1587203 to your computer and use it in GitHub Desktop.
自用豆瓣脚本
// ==UserScript==
// @name My Douban
// @namespace yesmeck.com
// @description 自用豆瓣脚本
// @include http://www.douban.com
// @include http://www.douban.com/*
// ==/UserScript==
var baseUrl = 'http://www.douban.com/';
var currentUrl = location.href;
//自动跳转到广播
if (currentUrl == baseUrl) {
location.href = baseUrl + 'update/';
}
if ('undefined' == typeof __PAGE_SCOPE_RUN__) {
//把当前脚本注入到页面
//http://wiki.greasespot.net/Content_Scope_Runner
(function page_scope_runner() {
var my_src = "(" + page_scope_runner.caller.toString() + ")();";
var script = document.createElement('script');
script.setAttribute("type", "text/javascript");
script.textContent = "var __PAGE_SCOPE_RUN__ = true;\n" + my_src;
setTimeout(function() {
document.body.appendChild(script);
document.body.removeChild(script);
}, 0);
})();
return;
} else {
Do(function() {
//我的提醒
$('.top-nav-info').prepend('<a href="' + baseUrl + 'notification/">提醒</a>');
//把豆瓣猜放最后面并修改链接
var items = $.makeArray($('.site-nav-items ul li'));
items.push(items.shift());
$('.site-nav-items ul').html(items);
$('.site-nav-items ul li a:last').attr('href', baseUrl + '#guess');
//换个链接
$('.site-nav-logo a, .top-nav-items ul li a:first').attr('href', baseUrl + 'update/');
//隐藏小组帖子里的图片
var i = 1;
$('.topic-figure.cc').each(function() {
var img = $(this).find('img');
var imgTitle = $(this).find('.topic-figure-title').html();
var href = img.attr('src');
var title = null != imgTitle ? imgTitle : '图片' + i;
$(this).html('<a href="' + href + '"> ' + title + ' </a>');
i++;
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment