|
// ==UserScript== |
|
// @name Better Douban Navigation |
|
// @author jnozsc |
|
// @namespace http://www.douban.com/people/1563045/ |
|
// @description I need a better douban navigation |
|
// @include http://www.douban.com/* |
|
// @match http://www.douban.com/* |
|
// @include http://book.douban.com/* |
|
// @match http://book.douban.com/* |
|
// @include http://music.douban.com/* |
|
// @match http://music.douban.com/* |
|
// @include http://movie.douban.com/* |
|
// @match http://movie.douban.com/* |
|
// @version 1.3 |
|
// ==/UserScript== |
|
function main($) { |
|
'use strict'; |
|
jQuery.noConflict(); |
|
|
|
var currentURL = document.URL; |
|
if ((currentURL.indexOf("www.douban.com") != -1) && (currentURL.indexOf("location") == -1)) { |
|
$('.site-nav-items > ul > li:nth-child(2)').hide(); |
|
$('.site-nav-items > ul > li:nth-child(1) > a').attr('href', 'http://www.douban.com/update/'); |
|
if (currentURL.indexOf("update") != -1) { |
|
$("title").text("首页"); |
|
} |
|
} |
|
$('.site-nav-logo > a').attr('href', 'http://www.douban.com/update/'); |
|
$('.top-nav-items > ul > li:nth-child(1) > a').attr('href', 'http://www.douban.com/update/'); |
|
|
|
} |
|
|
|
function thirdParty($) { |
|
'use strict'; |
|
jQuery.noConflict(); |
|
|
|
// Put third-party non-jQuery functions here. They'll be wrapped into the |
|
// jQuery prototype in a moment. |
|
var sayHello = function (who) { |
|
alert('Hello ' + who + '!'); |
|
} |
|
|
|
jQuery.extend({ |
|
// If you have any non-jQuery functions, they need to be wrapped in here. |
|
sayHellow: function (who) { |
|
return sayHello('World'); |
|
} |
|
|
|
}); |
|
|
|
// Put third-party jQuery plugins, extensions, etc. here |
|
} |
|
|
|
! |
|
function loader(i) { |
|
var script, requires = ['http://img3.douban.com/js/packed_jquery.min6301986802.js'], |
|
head = document.getElementsByTagName('head')[0], |
|
makeScript = function () { |
|
script = document.createElement('script'); |
|
script.type = 'text/javascript'; |
|
}, |
|
loadLocal = function (fn) { |
|
makeScript(); |
|
script.textContent = '(' + fn.toString() + ')(jQuery);'; |
|
head.appendChild(script); |
|
}; |
|
(function (i) { |
|
makeScript(); |
|
script.src = requires[i]; |
|
script.addEventListener('load', function () { |
|
++i !== requires.length ? loader(i) : (loadLocal(thirdParty), loadLocal(main)); |
|
}, true); |
|
head.appendChild(script); |
|
})(i || 0); |
|
}(); |