“我的好友”和“谁加我为好友”页面跳转。
目前為
// ==UserScript==
// @name 好友界面添加切换按钮
// @namespace http://tampermonkey.net/
// @version 0.1
// @description “我的好友”和“谁加我为好友”页面跳转。
// @author 鈴宮華緋
// @include /https?:\/\/(bgm\.tv|bangumi\.tv|chii\.in)\/user\/.*\/(rev_)?friends/
// ==/UserScript==
(function() {
let btn_action_css = {
'height' : '26px',
'color' : 'rgb(240, 145, 153)',
'background-color' : 'white',
'border' : 'solid 1px rgb(204, 204, 204)',
'border-bottom' : 'none',
'border-radius' : '5px 5px 0 0',
'padding' : '5px 10px',
'outline' : 'none'
};
let btn_normal_css = {
'height' : '26px',
'color' : 'rgb(240, 145, 153)',
'background-color' : 'transparent',
'border' : 'none',
'padding' : '5px 10px',
'outline' : 'none'
};
let rev_friend_btn = $('<button></button>');
rev_friend_btn.text('谁加我为好友');
rev_friend_btn.click(function() {
window.location.href = window.location.href.replace(/\/(rev_)?friend/,'/rev_friend');
});
let friend_btn = rev_friend_btn.clone();
friend_btn.text('我的好友');
friend_btn.click(function() {
window.location.href = window.location.href.replace(/\/(rev_)?friend/,'/friend');
});
if (window.location.pathname.match(/\/friend/)) {
friend_btn.css(btn_action_css);
rev_friend_btn.css(btn_normal_css);
} else if (window.location.pathname.match(/\/rev_friend/)) {
friend_btn.css(btn_normal_css);
rev_friend_btn.css(btn_action_css);
}
let btn_box = $('<div></div>');
btn_box.css({
'width' : '100%',
'height' : '25px',
'border-bottom' : 'solid 1px rgb(204, 204, 204)',
'padding-left' : '10px'
});
$('div#columnUserSingle').prepend(btn_box);
$(btn_box).append(friend_btn);
$(btn_box).append(rev_friend_btn);
})();