<commit_before>/* global $ requests server sidebar helper */
'use strict';
// ==UserScript==
// @name         MusicBrainz: Show missing works
// @namespace    mbz-loujine
// @author       loujine
// @version      2016.2.5
// @downloadURL  https://bitbucket.org/loujine/musicbrainz-scripts/raw/default/mbz-showmissingworks.user.js
// @updateURL    https://bitbucket.org/loujine/musicbrainz-scripts/raw/default/mbz-showmissingworks.user.js
// @supportURL   https://bitbucket.org/loujine/musicbrainz-scripts
// @icon         https://bitbucket.org/loujine/musicbrainz-scripts/raw/default/icon.png
// @description  musicbrainz.org: Mark recordings not linked to any work on a performer page
// @compatible   firefox+greasemonkey
// @licence      CC BY-NC-SA 3.0 (https://creativecommons.org/licenses/by-nc-sa/3.0/)
// @require      https://greasyfork.org/scripts/13747-mbz-loujine-common/code/mbz-loujine-common.js?version=125991
// @include      http*://*musicbrainz.org/artist/*/relationships
// @grant        none
// @run-at       document-end
// ==/UserScript==

// imported from mbz-loujine-common.js: requests, server, sidebar, helper


function showMissingWorks() {
    var $recordings = $('table a[href*="/recording/"]');
    if (!$('#workColumn').length) {
        $('thead > tr').append('<th id="workColumn">Related work</th>');
        $('.subh').append('<th>with date</th>');
    }

    $recordings.each(function (idx, recording) {
        setTimeout(function () {
            var url = helper.wsUrl('recording', ['work-rels']);
            requests.GET(url, function (response) {
                var resp = JSON.parse(response),
                    $node;
                if (resp.relations.length) {
                    if (resp.relations[0].begin) {
                        $node = $('<td>✓</td>').css('background-color',
                                                    'green');
                    } else {
                        $node = $('<td>⚠</td>').css('background-color',
                                                    'orange');
                    }
                } else {
                    $node = $('<td>✗</td>').css('background-color', 'red');
                }
                $(recording).parents('tr').append(
                    $node.css({'text-align': 'center',
                               'font-size': '100%'})
                );
            });
        }, idx * server.timeout);
    });
}

(function displaySidebar(sidebar) {
    sidebar.container().append(
        $('<h3>Linked works</h3>')
    ).append(
        $('<input>', {
            'id': 'showmissingworks',
            'type': 'button',<commit_msg>[missing works] Fix wrong requested mbid<commit_after>/* global $ requests server sidebar helper */
'use strict';
// ==UserScript==
// @name         MusicBrainz: Show missing works
// @namespace    mbz-loujine
// @author       loujine
// @version      2016.6.25
// @downloadURL  https://bitbucket.org/loujine/musicbrainz-scripts/raw/default/mbz-showmissingworks.user.js
// @updateURL    https://bitbucket.org/loujine/musicbrainz-scripts/raw/default/mbz-showmissingworks.user.js
// @supportURL   https://bitbucket.org/loujine/musicbrainz-scripts
// @icon         https://bitbucket.org/loujine/musicbrainz-scripts/raw/default/icon.png
// @description  musicbrainz.org: Mark recordings not linked to any work on a performer page
// @compatible   firefox+greasemonkey
// @licence      CC BY-NC-SA 3.0 (https://creativecommons.org/licenses/by-nc-sa/3.0/)
// @require      https://greasyfork.org/scripts/13747-mbz-loujine-common/code/mbz-loujine-common.js?version=133551
// @include      http*://*musicbrainz.org/artist/*/relationships
// @grant        none
// @run-at       document-end
// ==/UserScript==

// imported from mbz-loujine-common.js: requests, server, sidebar, helper


function showMissingWorks() {
    var $recordings = $('table a[href*="/recording/"]');
    if (!$('#workColumn').length) {
        $('thead > tr').append('<th id="workColumn">Related work</th>');
        $('.subh').append('<th>with date</th>');
    }

    $recordings.each(function (idx, recording) {
        setTimeout(function () {
            var mbid = recording.href.split('/')[4],
                url = helper.wsUrl('recording', ['work-rels'], mbid);
            requests.GET(url, function (response) {
                var resp = JSON.parse(response),
                    $node;
                if (resp.relations.length) {
                    if (resp.relations[0].begin) {
                        $node = $('<td>✓</td>').css('background-color',
                                                    'green');
                    } else {
                        $node = $('<td>⚠</td>').css('background-color',
                                                    'orange');
                    }
                } else {
                    $node = $('<td>✗</td>').css('background-color', 'red');
                }
                $(recording).parents('tr').append(
                    $node.css({'text-align': 'center',
                               'font-size': '100%'})
                );
            });
        }, 1.5 * idx * server.timeout);
    });
}

(function displaySidebar(sidebar) {
    sidebar.container().append(
        $('<h3>Linked works</h3>')
    ).append(
        $('<input>', {
            'id': 'showmissingworks',
            'type': 'button',
{'fraction_non_alphanumeric': 0.17014980580728686, 'fraction_numerical': 0.010726835583502866, 'mean_word_length': 1.8343815513626835, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2947182', 'n_tokens_mistral': 1682, 'n_tokens_neox': 1580, 'n_words': 260}