1
Fork 0

(allthethings)

This commit is contained in:
Jake Howard 2015-08-24 14:57:19 +01:00
parent 4bc4b791c2
commit 0fd819faae
12 changed files with 114 additions and 48 deletions

View file

@ -3,6 +3,6 @@
cp -r src/* build/
rm -rf build/injections/*
mkdir -p build/src/injections
for f in src/injections/*; do uglifyjs $f --compress --mangle --lint -o build/$f; done
for f in src/injections/*; do uglifyjs "src/image-decoder.js" "src/lib/jquery.js" $f --compress --screw-ie8 --define --stats --keep-fnames -o build/$f; done
cp -rp build/src/* build/
rm -rf build/src

View file

@ -21,7 +21,7 @@ for key, value in switcher.items():
manifest[value] = project_package[key]
with open(current_dir + "data/site-decoder.json") as json_file:
with open(current_dir + "data/decoder.json") as json_file:
site_decoder = json.load(json_file)['sites']
@ -29,8 +29,8 @@ content_scripts = []
for site in site_decoder:
site = list(site.items())[0]
temp = {}
temp['matches'] = [site[0]]
temp['js'] = ['data/lib/jquery.js', 'data/image_lookup.js', 'data/injections/' + site[1]]
temp['matches'] = ["*://" + site[0] + '/*']
temp['js'] = ['data/lib/jquery.js', 'data/image-decoder.js', 'data/injections/' + site[1]]
content_scripts.append(temp)

View file

@ -3,11 +3,21 @@
{
"js": [
"data/lib/jquery.js",
"data/image_lookup.js",
"data/image-decoder.js",
"data/injections/facebook.js"
],
"matches": [
"*.facebook.com"
"*://facebook.com/*"
]
},
{
"js": [
"data/lib/jquery.js",
"data/image-decoder.js",
"data/injections/github.js"
],
"matches": [
"*://github.com/*"
]
}
],

View file

@ -1,15 +1,22 @@
var self = require('sdk/self');
var pageMod = require("sdk/page-mod");
var sites = require("data/site-decoder.json").sites;
var sites = require("data/decoder.json").sites;
patterns = []
for (var i = 0; i < sites.length; i++) {
pattern = Object.keys(sites[i])[0];
script = sites[i][pattern];
content_scripts = ["./lib/jquery.js", "./image-lookup.js", "./injections/" + script];
console.log('pattern: ' + pattern);
console.log('content_scripts: ' + content_scripts);
pageMod.PageMod({
include: pattern,
contentScriptFile: content_scripts,
});
patterns.push(Object.keys(sites[i])[0])
}
pageMod.PageMod({
include: '*',
contentScriptFile: './../injector.js',
attachTo: 'top',
onAttach: function(worker) {
worker.port.emit('init');
},
contentScriptOptions: {
injectorURL: self.data.url('injections/'),
sites: require('data/decoder.json').sites,
}
});

18
firefox/injector.js Normal file
View file

@ -0,0 +1,18 @@
var injection_script = document.createElement('script');
injection_script.type = 'text/javascript';
sites = JSON.parse(self.options.sites);
console.log(sites);
console.log(sites[document.domain]);
if (self.options.sites.hasOwnProperty(document.domain)) {
self.port.on('init',function() {
injection_script.src=(self.options.injectorURL + self.options.site[document.domain]);
window.document.body.appendChild(injection_script);
});
console.log("Injector Imported");
} else {
console.log('No script');
}

6
src/decoder.json Normal file
View file

@ -0,0 +1,6 @@
{
"sites": [
{"facebook.com":"facebook.js"},
{"github.com":"github.js"}
]
}

3
src/image-decoder.js Normal file
View file

@ -0,0 +1,3 @@
window.image_decoder = {
"remember" : "https://dujrsrsgsd3nh.cloudfront.net/img/emoticons/23362/noot-1438871175.png"
}

View file

@ -1,4 +0,0 @@
var image_decoder = {
"form" : "https://dujrsrsgsd3nh.cloudfront.net/img/emoticons/23362/noot-1438871175.png"
}
console.log("Image Decoder imported");

View file

@ -1,8 +1,11 @@
var jq = jQuery.noConflict(true);
function change_chat_tabs() {
$('._d97').each(function(){
console.log("Event");
jq('._d97').each(function(){
for (var i = 0; i < image_decoder.length; i++) {
console.log('Checking for ' + image_decoder[i][0])
$(this).html($(this).html().replace(
jq(this).html(jq(this).html().replace(
image_decoder[i][0],
"<img class='emoticon' style='height: 30px; width: 30px;' src='" + image_decoder[i][1] + "'/>"
));
@ -11,32 +14,30 @@ function change_chat_tabs() {
}
$('.fbNubFlyout').on('DOMNodeInserted DOMNodeRemoved change load', function() { // Something changes inside the chat tab
jq('.fbNubFlyout').on('DOMNodeInserted DOMNodeRemoved change load', function() { // Something changes inside the chat tab
change_chat_tabs();
});
$('._d97').on('change load', function(){ // Chat Bubble messages
jq('._d97').on('change load', function(){ // Chat Bubble messages
change_chat_tabs();
});
$('.fbNubButton').on('click', function() { // Facebook tab button is clicked
jq('.fbNub').on('click', function() { // Facebook tab button is clicked
change_chat_tabs();
});
$('._55ln').on('click', function() { //Facebook sidebar person is clicked
jq('._55ln').on('click', function() { //Facebook sidebar person is clicked
change_chat_tabs();
})
$('._552m').on('input paste', function() { // Text change in textbox. Mainly used to cover all bases
jq('._552m').on('input paste', function() { // Text change in textbox. Mainly used to cover all bases
change_chat_tabs();
});
$(window).on('load', function() { // When window loads
change_chat_tabs();
});
change_chat_tabs();
alert("Facebook");

View file

@ -1,24 +1,56 @@
var jq = jQuery.noConflict(true);
function get_images() {
return JSON.parse('[{"(noot)" : "https://dujrsrsgsd3nh.cloudfront.net/img/emoticons/23362/noot-1438871175.png"}]');
}
function change_comments() {
$('.comment-body').each(function() {
for (var i = 0; i < image_decoder.length; i++) {
console.log('Checking for ' + image_decoder[i][0])
$(this).html($(this).html().replace(
image_decoder[i][0],
"<img style='height: 30px; width: 30px;' src='" + image_decoder[i][1] + "'/>"
window.image_decoder = get_images();
console.log("comment event");
jq('.comment-body').each(function() {
for (var i = 0; i < window.image_decoder.length; i++) {
key = Object.keys(window.image_decoder[i]);
image = window.image_decoder[key];
console.log('Checking for ' + key)
jq(this).html(jq(this).html().replace(
key,
"<img style='height: 30px; width: 30px;' src='" + image + "'/>"
));
}
});
}
$("button.btn[name='comment_and_close']").prev().on('click', function(){ // When the comment button is clicked
function change_readme() {
window.image_decoder = get_images();
console.log("readme event");
for (var i = 0; i < window.image_decoder.length; i++) {
key = Object.keys(window.image_decoder[i]);
image = window.image_decoder[i][key];
console.log('Checking for ' + key)
jq('#readme').html(jq('#readme').html().replace(
key,
"<img style='height: 30px; width: 30px;' src='" + image + "'/>"
));
}
}
jq("button.btn[name='comment_and_close']").prev().on('click', function(){ // When the comment button is clicked
change_comments();
});
$('.js-comment-container').on('load change', function(){ // when another comment comes in
jq('.js-comment-container').on('load change', function(){ // when another comment comes in
change_comments();
});
$(window).on('load', function(){ // When window loads
window.setInterval(function(){
change_comments();
});
change_readme();
}, 3000);
alert("Github");

1
src/lib/jquery.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,6 +0,0 @@
{
"sites": [
{"*.facebook.com":"facebook.js"},
{"*.github.com":"github.js"}
]
}