(allthethings)
This commit is contained in:
parent
4bc4b791c2
commit
0fd819faae
12 changed files with 114 additions and 48 deletions
|
@ -3,6 +3,6 @@
|
||||||
cp -r src/* build/
|
cp -r src/* build/
|
||||||
rm -rf build/injections/*
|
rm -rf build/injections/*
|
||||||
mkdir -p build/src/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/
|
cp -rp build/src/* build/
|
||||||
rm -rf build/src
|
rm -rf build/src
|
|
@ -21,7 +21,7 @@ for key, value in switcher.items():
|
||||||
manifest[value] = project_package[key]
|
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']
|
site_decoder = json.load(json_file)['sites']
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@ content_scripts = []
|
||||||
for site in site_decoder:
|
for site in site_decoder:
|
||||||
site = list(site.items())[0]
|
site = list(site.items())[0]
|
||||||
temp = {}
|
temp = {}
|
||||||
temp['matches'] = [site[0]]
|
temp['matches'] = ["*://" + site[0] + '/*']
|
||||||
temp['js'] = ['data/lib/jquery.js', 'data/image_lookup.js', 'data/injections/' + site[1]]
|
temp['js'] = ['data/lib/jquery.js', 'data/image-decoder.js', 'data/injections/' + site[1]]
|
||||||
content_scripts.append(temp)
|
content_scripts.append(temp)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,21 @@
|
||||||
{
|
{
|
||||||
"js": [
|
"js": [
|
||||||
"data/lib/jquery.js",
|
"data/lib/jquery.js",
|
||||||
"data/image_lookup.js",
|
"data/image-decoder.js",
|
||||||
"data/injections/facebook.js"
|
"data/injections/facebook.js"
|
||||||
],
|
],
|
||||||
"matches": [
|
"matches": [
|
||||||
"*.facebook.com"
|
"*://facebook.com/*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"js": [
|
||||||
|
"data/lib/jquery.js",
|
||||||
|
"data/image-decoder.js",
|
||||||
|
"data/injections/github.js"
|
||||||
|
],
|
||||||
|
"matches": [
|
||||||
|
"*://github.com/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,15 +1,22 @@
|
||||||
var self = require('sdk/self');
|
var self = require('sdk/self');
|
||||||
var pageMod = require("sdk/page-mod");
|
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++) {
|
for (var i = 0; i < sites.length; i++) {
|
||||||
pattern = Object.keys(sites[i])[0];
|
patterns.push(Object.keys(sites[i])[0])
|
||||||
script = sites[i][pattern];
|
}
|
||||||
content_scripts = ["./lib/jquery.js", "./image-lookup.js", "./injections/" + script];
|
pageMod.PageMod({
|
||||||
console.log('pattern: ' + pattern);
|
include: '*',
|
||||||
console.log('content_scripts: ' + content_scripts);
|
contentScriptFile: './../injector.js',
|
||||||
pageMod.PageMod({
|
attachTo: 'top',
|
||||||
include: pattern,
|
onAttach: function(worker) {
|
||||||
contentScriptFile: content_scripts,
|
worker.port.emit('init');
|
||||||
});
|
},
|
||||||
}
|
contentScriptOptions: {
|
||||||
|
injectorURL: self.data.url('injections/'),
|
||||||
|
sites: require('data/decoder.json').sites,
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
18
firefox/injector.js
Normal file
18
firefox/injector.js
Normal 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
6
src/decoder.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"sites": [
|
||||||
|
{"facebook.com":"facebook.js"},
|
||||||
|
{"github.com":"github.js"}
|
||||||
|
]
|
||||||
|
}
|
3
src/image-decoder.js
Normal file
3
src/image-decoder.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
window.image_decoder = {
|
||||||
|
"remember" : "https://dujrsrsgsd3nh.cloudfront.net/img/emoticons/23362/noot-1438871175.png"
|
||||||
|
}
|
|
@ -1,4 +0,0 @@
|
||||||
var image_decoder = {
|
|
||||||
"form" : "https://dujrsrsgsd3nh.cloudfront.net/img/emoticons/23362/noot-1438871175.png"
|
|
||||||
}
|
|
||||||
console.log("Image Decoder imported");
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
var jq = jQuery.noConflict(true);
|
||||||
|
|
||||||
function change_chat_tabs() {
|
function change_chat_tabs() {
|
||||||
$('._d97').each(function(){
|
console.log("Event");
|
||||||
|
jq('._d97').each(function(){
|
||||||
for (var i = 0; i < image_decoder.length; i++) {
|
for (var i = 0; i < image_decoder.length; i++) {
|
||||||
console.log('Checking for ' + image_decoder[i][0])
|
console.log('Checking for ' + image_decoder[i][0])
|
||||||
$(this).html($(this).html().replace(
|
jq(this).html(jq(this).html().replace(
|
||||||
image_decoder[i][0],
|
image_decoder[i][0],
|
||||||
"<img class='emoticon' style='height: 30px; width: 30px;' src='" + image_decoder[i][1] + "'/>"
|
"<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();
|
change_chat_tabs();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$('._d97').on('change load', function(){ // Chat Bubble messages
|
jq('._d97').on('change load', function(){ // Chat Bubble messages
|
||||||
change_chat_tabs();
|
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();
|
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();
|
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();
|
change_chat_tabs();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$(window).on('load', function() { // When window loads
|
change_chat_tabs();
|
||||||
change_chat_tabs();
|
|
||||||
});
|
|
||||||
alert("Facebook");
|
alert("Facebook");
|
|
@ -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() {
|
function change_comments() {
|
||||||
$('.comment-body').each(function() {
|
window.image_decoder = get_images();
|
||||||
for (var i = 0; i < image_decoder.length; i++) {
|
console.log("comment event");
|
||||||
console.log('Checking for ' + image_decoder[i][0])
|
jq('.comment-body').each(function() {
|
||||||
$(this).html($(this).html().replace(
|
for (var i = 0; i < window.image_decoder.length; i++) {
|
||||||
image_decoder[i][0],
|
key = Object.keys(window.image_decoder[i]);
|
||||||
"<img style='height: 30px; width: 30px;' src='" + image_decoder[i][1] + "'/>"
|
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();
|
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();
|
change_comments();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on('load', function(){ // When window loads
|
|
||||||
|
window.setInterval(function(){
|
||||||
change_comments();
|
change_comments();
|
||||||
});
|
change_readme();
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
alert("Github");
|
alert("Github");
|
1
src/lib/jquery.js
vendored
1
src/lib/jquery.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"sites": [
|
|
||||||
{"*.facebook.com":"facebook.js"},
|
|
||||||
{"*.github.com":"github.js"}
|
|
||||||
]
|
|
||||||
}
|
|
Reference in a new issue