您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
Inserts movie ratings from tmdb into trakt. credits to
当前为
// ==UserScript== // @name trakt.tv with tmdb rating // @author NKay08 // @description Inserts movie ratings from tmdb into trakt. credits to // http://greasyfork.icu/de/scripts/9613-trakt-tv-add-imdb-rottentomatoes-movie-ratings-and-sorting-options-for-ratings // @namespace http://greasyfork.icu/de/users/155913-nkay08 // @include /^https?://(.+\.)?trakt\.tv/?.*$/ // @exclude /^https?://(.+\.)?trakt\.tv/(shows|calendars)/?.*$/ // // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js // // @grant GM_xmlhttpRequest // // // @version 0.0.1.20171023084200 // ==/UserScript== (function ($) { 'use strict'; /*jslint browser: true, regexp: true, newcap: true*/ /*global jQuery, GM_xmlhttpRequest */ $.noConflict(); var loadRatingsForItem = function () { tmdb = $('<h3>', { 'class': 'ratings', 'html': '<div style="float: left; width: 97px;">R.T. / TMDB</div><span class="value"> </span>' }), dummy = $('<h3>', { 'class': 'ratings', 'style': 'opacity: 0.8; height: 18px;' }), url = $(this).attr('data-url'); if ($(this).attr('data-type') !== 'movie') { $(this).find('.quick-icons').after(dummy).after(dummy.clone()); } else { $(this).find('.quick-icons').after(tmdb); if (url) { } }, parseRating = function (item, type) { var r; if (type === 'originalOrder') { return $(item).attr('startOrder'); } if (type === 'trakt') { r = $(item).find("div.percentage").text().slice(0, -1); if (r !== null && r >= 0 && r <= 100) { return r; } } if (type === 'tmdb') { r = 1; } } return -1; }, sortByRating = function (e) { var items, order, dict = {}, parent = $("div.grid-item").parent(), how = function (a, b) { return a - b; }; $(".no-top").hide(); if ($('#sortable-name').size() > 0) { $('#sortable-name').text($(e.target).text()).attr('data-sort-by', $(e.target).attr('data-sort-by')); } else { $('.trakt-icon-swap-vertical').next().find('.btn-default').html($(e.target).text() + ' <span class="caret"></span>'); } $("div.grid-item").each(function () { var rating = parseRating(this, $(e.target).attr('data-sort-by')); if (dict[rating] === undefined) { dict[rating] = [$(this)]; } else { dict[rating].push($(this)); } }); if ($('#sort-direction').hasClass('desc')) { how = function (b, a) { return a - b; }; } order = Object.keys(dict).sort(how); while (order.length > 0) { items = dict[order.pop()]; while (items.length > 0) { parent.append(items.shift()); } } }, setPositioning = function () { setTimeout(function () { if ($('.trakt-icon-swap-vertical').next().find('a.rating:contains("' + $('.trakt-icon-swap-vertical').next().find('.btn-default').text().trim() + '")').size() > 0) { $("div.grid-item").each(function () { $(this).attr('style', '{position:relative;top:0px;left:0px;}'); }); } else if ($('.grid-item').first().attr('style') !== undefined) { $("div.grid-item").each(function () { $(this).css('position', 'absolute'); }); } }, 500); }, init = function () { $("div[id*=\"huckster-desktop\"]").html(""); if (/^\/users\/.+\/(collection|ratings|lists\/|watchlist)/.test(window.location.pathname) && $('.trakt-icon-swap-vertical').next().find('ul a.rating').size() === 0) { var sortMenu = $('.trakt-icon-swap-vertical').next().find('ul'); sortMenu.append($('<li>', { html: "<a class='rating' data-sort-by='tmdb' data-sort-how='desc'>tmdb rating</a>" })); sortMenu.find('a.rating').click(sortByRating); sortMenu.find('a').click(setPositioning); $(window).on('resize', setPositioning); $('#sort-direction').click(function () { $('.trakt-icon-swap-vertical').next().find('a.rating:contains("' + $('.trakt-icon-swap-vertical').next().find('.btn-default').text().trim() + '")').click(); }); } else { $(window).off('resize', setPositioning); } if ($("div.grid-item[data-type='movie']").size() > 0) { $("div.grid-item").not('.ratingsloaded').each(loadRatingsForItem); } }; $(window).ready(function () { $('head').append('<style>h3.ratings, h3.ratings a { padding-top:4px!important; padding-bottom:0px!important; padding-left: 5px!important; margin-top: 0px!important; margin-left:1px!important; margin-right:1px!important; background-color: #292D41; color: white; font-size: 10px!important; text-align: left!important; };</style>'); $('head').append('<style>span.value, span.value>a { padding-left: 4px!important; font-weight: bolder!important; font-size: 12px!important; };</style><style>.quick-icons { border-bottom:none!important; };</style>'); init(); $(window).on('DOMNodeInserted', function (e) { if (e.target.tagName === 'BODY') { $(e.target).ready(init); } }); }); }(jQuery));