GetRec'd: AO3

adds recommendations to archiveofourown.org

目前為 2017-02-08 提交的版本,檢視 最新版本

// ==UserScript==
// @name        GetRec'd: AO3
// @namespace   http://archiveofourown.org
// @description adds recommendations to archiveofourown.org
// @include     http://archiveofourown.org/works/*
// @exclude     http://archiveofourown.org/works/search*
// @version     1.2
// @require     http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @grant       none
// ==/UserScript==
/***** 
 
  A note on privacy: This script sends data about the AO3 work you are viewing to a web server where it is stored in a database. 
  This process is anonymous and no information about you or your habits are collected. 
 
  Project blog: get-recd.tumblr.com

 *****/

(function() {
    'use strict';

    $(document).ready(function(){
        var usersAll = [];
        var users;

        $('#workskin')
            .append('<div id="rec-box"><hr><br></div>')
            .find('#rec-box')
            .toggle(false);

        $('#feedback ul.actions:nth-of-type(1)')
            .prepend('<a id="rec-button">You might also like...</a>')
            .on('click', '#rec-button', function(){
            console.log('click!');
            $('#rec-box').toggle();
        });
        $('.kudos  a:not(#kudos_summary, #kudos_collapser)').each(function () {
            usersAll.push($(this).text());
        });

        if ( usersAll.length < 8 ) {
            $('#rec-box').append('<p>No recs yet! More users need to leave kudos on this work.</p>');
        } else {
            var title = $('#workskin .preface h2.title').text();
            var category = [];

            $('.meta .fandom ul li a.tag').each(function () {
                category.push($(this).text());
            });

            if (usersAll.length > 5000) {
                users = usersAll.slice(0, 5000);              
            } else {
                users = usersAll;
            }

            var workData = {
                users: users,
                name: title,
                category: category
            };
     
            $.post('https://intense-reef-64978.herokuapp.com/', workData).done(function(res) {
                var data = JSON.parse(res);
                console.log('loaded');
                console.log('res',res);
                console.log('data', data);
                var message = data.fail;

                if (data.fail && !message) {
                    $('#rec-box')
                        .append('<p>Oops! Something went wrong :( </p><br><a href="http//:get-recd.tumblr.com">Report a problem</a>');  
                } else if (message){
                    $('#rec-box')
                        .append('<p>Oops! ' + message + '</p><br><p>The more people use Get Rec\'d, the more accurate it will be. Spread the word! </p><br> <a href="http://get-recd.tumblr.com">Report a problem</a>');
                } else {
                    $(data.data).each(function() {
                        var recID = this._id;
                        var recTitle = this.name;
                        var recCategory = this.category;

                        $('#rec-box')
                            .append('<h4><a href="http://archiveofourown.org/works/' + recID  + '">' + recTitle + '</a></h4><h5>' + recCategory +'</h5><br>'); 
                    });
                }
            });
        }
    });

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址