Created
December 4, 2012 17:08
-
-
Save zztczcx/4206332 to your computer and use it in GitHub Desktop.
v2ex-reply-lookback.user.js
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== | |
// @name v2ex-reply-lookback | |
// @namespace http://imissing.de | |
// @author zztczcx<[email protected]> | |
// @description 在@的用户链接上点击鼠标中间,跳转到该用户(如果存在)的第一条发言,并用颜色标记本条回复之前的其所有发言 | |
// @include http://www.v2ex.com/go/* | |
// @include http://www.v2ex.com/t/* | |
// @include http://v2ex.com/t/* | |
// @include http://www.v2ex.com/?tab=* | |
// @include http://v2ex.com/?tab=* | |
// @include http://www.v2ex.com/ | |
// @include http://v2ex.com/ | |
// @version 0.1 | |
// @grant none | |
// ==/UserScript==\ | |
(function() { | |
window.unsafeWindow || ( | |
unsafeWindow = (function() { | |
var el = document.createElement('p'); | |
el.setAttribute('onclick', 'return window;'); | |
return el.onclick(); | |
}()) | |
); | |
var $ = unsafeWindow.jQuery; | |
$("<style>.color-change{background-color:#fffbc1;}</style>").appendTo('body') | |
$('.reply_content a').on("click ",function(event){ | |
if(event.ctrlKey){ | |
var self = $(this) | |
var user_lookback = self.html() | |
var jump_top; | |
if(this.previousSibling.data == "@"){ | |
$('.color-change').toggleClass('color-change') | |
var self_wrap = self.parents('.cell') | |
self_wrap.prevAll().find('strong a').each(function(){ | |
var _self=$(this) | |
if (_self.html() == user_lookback){ | |
_self.parents('.cell').addClass('color-change') | |
jump_top = _self.offset().top | |
} | |
}) | |
$('body,html').animate({ | |
scrollTop:jump_top | |
},400) | |
} | |
return false | |
} | |
}) | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment