Author

Topic: Free BitcoinTalk notification extension for Chrome & Opera (Read 651 times)

copper member
Activity: 3948
Merit: 2201
Verified awesomeness ✔
Is there a way to check whether this extension is safe? Beside that, this is the extension I've been waiting for.
I know you like to post crap to get more BTC, but at least try to read the thread. I've already examined the code and marked it as safe.

Can you post the source code so that people can examine it?

Mitchell did it already as you can see on this thread: https://bitcointalksearch.org/topic/free-bitcointalk-notification-extension-for-chrome-opera-1169316
Link to the post itself: click
sr. member
Activity: 392
Merit: 251
Is there a way to check whether this extension is safe? Beside that, this is the extension I've been waiting for.
staff
Activity: 3458
Merit: 6793
Just writing some code
Can you post the source code so that people can examine it?

Mitchell did it already as you can see on this thread: https://bitcointalksearch.org/topic/free-bitcointalk-notification-extension-for-chrome-opera-1169316
Thanks.

I can't alert ppl when there is a thread. I should check all the sections then every minute, and I don't think the BT staff would like that. This would also take up a lot of bandwidth. If they would make a feature/API theirself it would be possible.
You could have it check the recents page here https://bitcointalk.org/index.php?action=recent and notify when a post is made that doesn't have "Re:" in the title.

Can you also have it check the watchlist and notify us when a new reply was posted to a topic we are watching?
copper member
Activity: 1498
Merit: 1528
No I dont escrow anymore.
-snip-
I can't alert ppl when there is a thread. I should check all the sections then every minute, and I don't think the BT staff would like that. This would also take up a lot of bandwidth. If they would make a feature/API theirself it would be possible.

Could you request the watchlist page and modify the link from Watchlist to Watchlist[#unread threads]?

That way you only request a single page every e.g. 10-30 seconds (should be enough) and the user only gets a message for a board they actually watch and not for boards they dont care about.
member
Activity: 67
Merit: 10
member
Activity: 67
Merit: 10
Can you post the source code so that people can examine it?

Mitchell did it already as you can see on this thread: https://bitcointalksearch.org/topic/free-bitcointalk-notification-extension-for-chrome-opera-1169316
staff
Activity: 3500
Merit: 6152
Can you post the source code so that people can examine it?

I'am not sure if this is the full code because I got other files but I guess this is the part that gets the PMs etc .. you could use an extention on google chrome that allow you to see source codes of extensions .

Code:
(function(window) {
    var BTC = {
        appversion: "1.0.1",
        pms: [],
        Init: function() {
            BTC.OPT.Check();
            BTC.bg.Init();
            chrome.notifications.onButtonClicked.addListener(BTC.handlers.notificationButtonClicked);
        },
        handlers: {
            notificationButtonClicked: function(notificationId, buttonIndex) {
                if (notificationId.substr(0, 5) == 'BTCPM' && !isNaN(parseInt(notificationId.substr(5)))) {
                    var pm = BTC.pms[parseInt(notificationId.substr(5))];
                    if (buttonIndex == 0) {
                        chrome.tabs.create({
                            url: 'https://bitcointalk.org/index.php?action=pm#msg' + pm.id
                        });
                    } else {
                        chrome.tabs.create({
                            url: 'https://bitcointalk.org/index.php?action=profile;u=' + pm.sender.id
                        });
                    }
                }
            }
        },
        OPT: {
            Get: function(c) {
                return localStorage.getItem(c)
            },
            Set: function(c, d) {
                return localStorage.setItem(c, d)
            },
            Remove: function(c) {
                return localStorage.removeItem(c)
            },
            Reset: function() {
                localStorage.clear();
                BTC.OPT.Check();
            },
            Check: function() {
                if (BTC.OPT.Get("APILastPM") == null) {
                    BTC.OPT.Set("APILastPM", 0)
                }
                if (BTC.OPT.Get("PMCheckDelay") == null || parseInt(BTC.OPT.Get("PMCheckDelay")) != BTC.OPT.Get("PMCheckDelay") || BTC.OPT.Get("PMCheckDelay") < 20 * 1000) {
                    BTC.OPT.Set("PMCheckDelay", 100000)
                }
            }
        },
        API: {
            getPMS: function(callback) {
                $.get('https://bitcointalk.org/index.php?action=pm')
                    .always(function(data) {
                        var pms = $($(data)[42])
                            .find('table > tbody > tr > td > form > table > tbody > tr[class^="windowbg"]');
                        if (pms.length > 0) {
                            var cleanpms = {};
                            pms.each(function() {
                                var pmdata = $(this)
                                    .find('td');
                                var status = pmdata.eq(0)
                                    .find('img')
                                    .attr('alt');
                                var pminfo = {
                                    subject: pmdata.eq(2)
                                        .find('a')
                                        .text(),
                                    id: parseInt(pmdata.eq(2)
                                        .find('a')
                                        .attr('href')
                                        .replace('#msg', '')),
                                    readed: (status == 'Read' || status == 'Replied To'),
                                    replied: (status == 'Replied To'),
                                    date: pmdata.eq(1)
                                        .text(),
                                    sender: {
                                        username: pmdata.eq(3)
                                            .find('a')
                                            .text(),
                                        id: parseInt(pmdata.eq(3)
                                            .find('a')
                                            .attr('href')
                                            .split(';u=')[1])
                                    }
                                };
                                cleanpms[pminfo.id] = pminfo;
                            });
                            callback(cleanpms);
                        } else {
                            callback(false);
                        }
                    });
            },
            getAvatar: function(user, callback) {
                $.get('https://bitcointalk.org/useravatars/avatar_' + user + '.png')
                    .always(function(plain, success, raw) {
                        callback((raw.status == 200) ? 'https://bitcointalk.org/useravatars/avatar_' + user + '.png' : '/assets/icon_128.png');
                    });
            }
        },
        bg: {
            timer: null,
            Init: function(c) {
                if (c != false) {
                    BTC.bg.tick();
                }
            },
            tick: function() {
                var delay = BTC.OPT.Get("PMCheckDelay") || 100000;
                BTC.bg.timer = setTimeout(function() {
                    BTC.bg.tick()
                }, delay);
                BTC.API.getPMS(BTC.bg.handlePMS);
            },
            handlePMS: function(pms) {
                BTC.pms = pms;
                if (Object.keys(pms)
                    .length > 0) {
                    // More than 1 PM
                    var highestPM = BTC.OPT.Get("APILastPM");
                    $.each(pms, function() {
                        var pm = this;
                        if (pm.id > BTC.OPT.Get("APILastPM")) {
                            highestPM = Math.max(highestPM, pm.id);
                            BTC.API.getAvatar(pm.sender.id, function(avatar) {
                                chrome.notifications.create('BTCPM' + pm.id, {
                                    type: 'basic',
                                    iconUrl: avatar,
                                    title: 'Private message from ' + pm.sender.username,
                                    message: pm.subject,
                                    buttons: [{
                                        title: 'View PM'
                                    }, {
                                        title: 'View sender profile'
                                    }],
                                    isClickable: false
                                });
                            });
                        }
                    });
                    BTC.OPT.Set("APILastPM", highestPM);
                }
            }
        }
    };
    window.BTC = BTC
})(window);
$(document)
    .ready(window.BTC.Init);


Code:
{
    "update_url": "https://clients2.google.com/service/update2/crx",
    "name": "BitcoinTalk",
    "description": "This application will give you a notification when you receive a private message on BitcoinTalk",
    "version": "1.0.1",
    "manifest_version": 2,
    "icons": {
        "32": "/assets/icon_32.png",
        "57": "/assets/icon_57.png",
        "64": "/assets/icon_64.png",
        "128": "/assets/icon_128.png",
        "256": "/assets/icon_256.png",
        "512": "/assets/icon_512.png"
    },
    "homepage_url": "https://bitcointalk.org/",
    "offline_enabled": false,
    "background": {
        "page": "/background.html"
    },
    "permissions": [
        "notifications",
        "tabs",
        "webRequest",
        ""
    ],
    "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
}


@OP , could you please consider making an extension that checks and watch sections then notify us when a new thread it's made ? that would be awesome ! It's boring to click "Watchlist" each time and you don't know when there is one .
staff
Activity: 3458
Merit: 6793
Just writing some code
Can you post the source code so that people can examine it?
member
Activity: 67
Merit: 10
Hello everyone!
 
Few weeks ago I decided to create an extension to make our life easier at Bitcointalk. This sends you a notification when you receive a PM, even when you're not on the site. You won't miss a single message anymore!


 
If there are any bugs don't be scared and just post a comment or PM me. Also, if you want a new feature I would love to get in touch with you.
 
At the moment the extension is only available for Google Chrome and Opera in the Google Chrome Webstore. It is free to download:
https://chrome.google.com/webstore/detail/bitcointalk/cmjgajfcdgnahghegnegjiapoclkfcpp
 
IMPORTANT INSTRUCTIONS: You don't have to log in in the extension. The extension automatically checks the PM-page every 2 minutes so you have to be logged in to receive notifications.
 
Greetings
Jump to: