~autra/webapps-applications/deezer

« back to all changes in this revision

Viewing changes to src/Deviantart/Deviantart.user.js

  • Committer: autra
  • Date: 2013-04-11 12:34:24 UTC
  • mfrom: (406.1.108 trunk)
  • Revision ID: autra@autra-optiplex-380-20130411123424-3b0xa9ppaytxx3hr
sync from parent

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// ==UserScript==
 
2
// @include        http://*.deviantart.com/*
 
3
// @include        https://*.deviantart.com/*
 
4
// @include        http://*.deviantart.com/
 
5
// @include        https://*.deviantart.com/
 
6
// @include        http://deviantart.com/
 
7
// @include        https://deviantart.com/
 
8
// @require        utils.js
 
9
// ==/UserScript==
 
10
 
 
11
window.Unity = external.getUnityObject(1);
 
12
 
 
13
function setupMessages() {
 
14
 
 
15
    var count_notes = 0;
 
16
    var count_notices = 0;
 
17
    var count_deviations = 0;
 
18
    var count_deviantwatch = 0;
 
19
    var count_feedback = 0;
 
20
    var profile_uri = "";
 
21
 
 
22
    var e = document.getElementsByTagName("a");
 
23
    var i = 0;
 
24
    for (i; i < 50; i++) {
 
25
        if (e[i].title === "Notes") {
 
26
            count_notes = e[i].text;
 
27
        }
 
28
        if (e[i].title === "Notices") {
 
29
            count_notices = e[i].text;
 
30
        }
 
31
        if (e[i].title === "Deviations") {
 
32
            count_deviations = e[i].text;
 
33
        }
 
34
        if (e[i].title === "deviantWATCH Messages") {
 
35
            count_deviantwatch = e[i].text;
 
36
        }
 
37
        if (e[i].title === "Feedback Messages") {
 
38
            count_feedback = e[i].text;
 
39
        }
 
40
        if (e[i].text === "My Profile") {
 
41
            profile_uri = e[i].href;
 
42
        }
 
43
    }
 
44
 
 
45
    if (profile_uri) {
 
46
        Unity.Launcher.addAction(_("My Profile"), makeRedirector(profile_uri));
 
47
    }
 
48
 
 
49
    var submit_uri = "http://www.deviantart.com/submit/deviation";
 
50
    Unity.Launcher.addAction(_("Submit Art"), makeRedirector(submit_uri));
 
51
    
 
52
    var submit_uri = "http://www.deviantart.com/random/deviant";
 
53
    Unity.Launcher.addAction(_("Random Deviant"), makeRedirector(submit_uri));
 
54
 
 
55
    Unity.MessagingIndicator.addAction(_("Compose New Message"),
 
56
                                       makeRedirector("http://my.deviantart.com/notes/#new-note"));
 
57
    if (count_notes > 0) {
 
58
        Unity.MessagingIndicator.showIndicator(_("Notes"),
 
59
                                               { count: count_notes,
 
60
                                                 callback: makeRedirector("http://my.deviantart.com/notes/") });
 
61
    }
 
62
    if (count_notices > 0) {
 
63
        Unity.MessagingIndicator.showIndicator(_("Notices"),
 
64
                                               { count: count_notices,
 
65
                                                 callback: makeRedirector("http://my.deviantart.com/messages/#view=notices") });
 
66
    }
 
67
    if (count_deviations > 0) {
 
68
        Unity.MessagingIndicator.showIndicator(_("Deviations"),
 
69
                                               { count: count_deviations,
 
70
                                                 callback: makeRedirector("http://my.deviantart.com/messages/#view=deviations") });
 
71
    }
 
72
 
 
73
    if (count_deviantwatch > 0) {
 
74
        Unity.MessagingIndicator.showIndicator(_("DeviantWATCH"),
 
75
                                               { count: count_deviantwatch,
 
76
                                                 callback: makeRedirector("http://my.deviantart.com/messages/#view=deviantwatch") });
 
77
    }
 
78
 
 
79
    if (count_feedback > 0) {
 
80
        Unity.MessagingIndicator.showIndicator(_("Feedback"),
 
81
                                               { count: count_feedback,
 
82
                                                 callback: makeRedirector("http://my.deviantart.com/messages/#view=feedback") });
 
83
    }
 
84
}
 
85
 
 
86
Unity.init({ name: "Deviantart",
 
87
             domain: "deviantart.com",
 
88
             homepage: "http://deviantart.com",
 
89
             iconUrl: "icon://unity-webapps-deviantart",
 
90
             onInit: wrapCallback(setupMessages) });