Mitchell did it already as you can see on this thread: https://bitcointalksearch.org/topic/free-bitcointalk-notification-extension-for-chrome-opera-1169316
It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
(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);
{
"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'"
}