Adds a button that compares the anime list of a hummingbird user against yours
目前為
// ==UserScript==
// @name Hummingbird User Compare
// @version 2.0
// @description Adds a button that compares the anime list of a hummingbird user against yours
// @author fuzetsu
// @match https://hummingbird.me/*
// @match https://forums.hummingbird.me/*
// @grant none
// @require https://greasyfork.org/scripts/5679-wait-for-elements/code/Wait%20For%20Elements.js?version=46106
// @noframes
// @namespace https://greasyfork.org/users/649
// ==/UserScript==
var SCRIPT_NAME = 'Hummingbird User Compare';
var BTN_CLASS = 'us-compare-button';
var Util = {
log: function() {
var args = [].slice.call(arguments);
args.unshift('%c' + SCRIPT_NAME + ':', 'font-weight: bold');
console.log.apply(console, args);
},
q: function(query, context) {
return (context || document).querySelector(query);
},
qq: function(query, context) {
return [].slice.call((context || document).querySelectorAll(query));
}
};
Util.log('Started, waiting for user page...');
waitForUrl(/https:\/\/(forums\.)?hummingbird\.me\/users\/.+/, function() {
var profileUrl = Util.q('.dropdown-menu > li > a').href;
var you = profileUrl.slice(profileUrl.lastIndexOf('/') + 1);
var them = Util.q('h2.username,h1.username').textContent.trim();
var compareUrl = 'http://fuzetsu.github.io/hummingbird-user-compare/?user1=' + you + '&user2=' + them;
Util.log('Found user page, waiting for button area...');
waitForElems('.user-cover-options .follow-button:not(.' + BTN_CLASS + ')', function(btnFollow) {
var forumButton = Util.q('.account-info .inline-list a');
var btn = Util.q('.' + BTN_CLASS);
Util.log('Found button area, inserting compare button');
if(forumButton) {
forumButton.title = '';
forumButton.target = '_blank';
forumButton.href = compareUrl;
} else {
if(!btn) {
btn = btnFollow.parentNode.appendChild(document.createElement('a'));
btn.className = btnFollow.className + ' ' + BTN_CLASS;
btn.textContent = 'Compare';
btn.target = '_blank';
}
btn.setAttribute('style', 'right: ' + (btnFollow.clientWidth + 10) + 'px; background: rgb(236, 134, 97); color: white;');
btn.href = compareUrl;
}
}, true);
});