UserNotes

Скрипт для Лепры, позволяющий видеть, добавлять и изменять заметки прямо в посте и на глагне

Stan na 25-07-2014. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name          UserNotes
// @author        Gipnokote
// @version       1.0
// @namespace     https://leprosorium.ru/*
// @include       https://*leprosorium.ru/*
// @description   Скрипт для Лепры, позволяющий видеть, добавлять и изменять заметки прямо в посте и на глагне
// ==/UserScript==



unsafeWindow.getNote = function(user_id){
    var userLinks = $$('div.ddi a.c_user[data-user_id='+user_id+']');
    var userNotes = $$('div.ddi span.usernote_'+user_id);
    userNotes.destroy();
    var noteRequest = new Request({
        url: '/ajax/user/note/get/',
        method: 'post',
        onSuccess: function(responseText){
            var response = JSON.decode(responseText);
            if (response.user_note) {
                userLinks.map(function injectNotes(userLink) {
                    var userNote = new Element('span', {class: 'usernote_'+user_id, html: ', [<span style="color:green;cursor:pointer;" onClick="setUserNote('+user_id+');">'+response.user_note.body+'</span>]'});
                    userNote.inject(userLink, 'after');
                });
            } else {
                userLinks.map(function injectNotes(userLink) {
                    var userNote = new Element('span', {class: 'usernote_'+user_id, html: ', [<span style="color:green;cursor:pointer;" onClick="setUserNote('+user_id+');">+</span>]'});
                    userNote.inject(userLink, 'after');
                });
            }
        }
    });
    noteRequest.send('user='+user_id+'&csrf_token='+globals.user['csrf_token']);
}

var uids = [].combine($$('div.ddi a.c_user').getProperty('data-user_id'));

uids.map(function process(uid){
    getNote(uid);
});

unsafeWindow.setNote = function (user_id, note){
    var result = '';
    var noteRequest = new Request({
        url: '/ajax/user/note/set/',
        method: 'post'
    });
    noteRequest.send('user='+user_id+'&note='+note+'&csrf_token='+globals.user['csrf_token']);
    getNote(user_id);
}

unsafeWindow.setUserNote = function (user_id){
    var z = prompt('Введите заметку:','');
    if (z!=null) {
        setNote(user_id, z);
    }
}