diff --git a/assets/allthethings.png b/assets/allthethings.png
new file mode 100644
index 0000000..6243a18
Binary files /dev/null and b/assets/allthethings.png differ
diff --git a/assets/build-assets.py b/assets/build-assets.py
new file mode 100644
index 0000000..5760fc0
--- /dev/null
+++ b/assets/build-assets.py
@@ -0,0 +1,25 @@
+import json, os
+from base64 import b64encode
+from glob import glob
+
+def get_filename(path):
+ return path.replace('assets/', "").replace('.png', '')
+
+
+files = glob('assets/*.png')
+image_bin = []
+
+for filename in files:
+ with open(filename, 'rb') as file:
+ image_bin.append({ get_filename(filename): "data:image/png;base64,"+ (str(b64encode(file.read()))[2:-1])})
+
+image_decoder = {"sites":image_bin}
+
+image_decoder_json = json.dumps(image_decoder, indent=2, sort_keys=True)
+
+js_file = None
+with open('src/image-decoder.js', "r") as file:
+ js_file = file.read()
+js_file = js_file.replace("%image_decoder%", image_decoder_json)
+with open('build/image-decoder.js', 'w') as file:
+ file.write(js_file)
diff --git a/assets/noot.png b/assets/noot.png
new file mode 100644
index 0000000..024c89f
Binary files /dev/null and b/assets/noot.png differ
diff --git a/build-js.sh b/build-js.sh
index 2cd292f..37ec98d 100644
--- a/build-js.sh
+++ b/build-js.sh
@@ -1,8 +1,10 @@
#!/usr/bin/bash
-cp -r src/* build/
+cp -r src/lib/* build/lib/
+cp -r src/decoder.json build/
rm -rf build/injections/*
mkdir -p build/src/injections
-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
+uglifyjs build/image-decoder.js --compress --screw-ie8 --define --keep-fnames -o build/image-decoder.js
+for f in src/injections/*; do uglifyjs "build/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
\ No newline at end of file
diff --git a/firefox/index.js b/firefox/index.js
index e7214b4..641421d 100644
--- a/firefox/index.js
+++ b/firefox/index.js
@@ -2,21 +2,14 @@ var self = require('sdk/self');
var pageMod = require("sdk/page-mod");
var sites = require("data/decoder.json").sites;
-patterns = []
-
for (var i = 0; i < sites.length; i++) {
- 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,
-
- }
-});
\ No newline at end of file
+ site = Object.keys(sites[i]);
+ script = sites[i][site];
+ site = '*.' + site;
+ console.log("SS: " + site + " " + script);
+ pageMod.PageMod({
+ include: site,
+ contentScriptFile: './injections/' + script,
+ attachTo: ['top', 'existing', 'iframe'],
+ });
+}
\ No newline at end of file
diff --git a/firefox/injector.js b/firefox/injector.js
deleted file mode 100644
index 34d590f..0000000
--- a/firefox/injector.js
+++ /dev/null
@@ -1,18 +0,0 @@
-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');
-}
\ No newline at end of file
diff --git a/firefox/package.json b/firefox/package.json
index 4e4c853..a54314f 100644
--- a/firefox/package.json
+++ b/firefox/package.json
@@ -1,14 +1,14 @@
{
- "author": "TheOrangeOne",
- "description": "Use hipchat emoticons on other sites",
+ "author": "TheOrangeOne",
+ "description": "Use hipchat emoticons on other sites",
"engines": {
- "fennec": ">=38.0a1",
+ "fennec": ">=38.0a1",
"firefox": ">=38.0a1"
- },
- "id": "Hipchat-Emoticons-for-all@jetpack",
- "license": "MIT",
- "main": "index.js",
- "name": "hipchat emoticons for all",
- "title": "Hipchat-Emoticons-for-all",
+ },
+ "id": "Hipchat-Emoticons-for-all@jetpack",
+ "license": "MIT",
+ "main": "index.js",
+ "name": "hipchat emoticons for all",
+ "title": "Hipchat-Emoticons-for-all",
"version": "0.0.0"
}
\ No newline at end of file
diff --git a/package.json b/package.json
index 41e3976..c626651 100644
--- a/package.json
+++ b/package.json
@@ -10,9 +10,10 @@
"build-chrome": "crx pack chrome -o chrome/hipchat-emoticons-for-all.crx -p chrome/key.pem",
"test-firefox": "cd firefox/ && jpm run -b /usr/bin/firefox && cd -",
"build-js": "bash build-js.sh",
+ "build-assets": "python assets/build-assets.py",
"build-data-files": "python firefox/build-package.py && python chrome/build-manifest.py",
"distribute": "rm -rf firefox/data/* chrome/data/* && cp -rf build/* firefox/data/ && cp -rf build/* chrome/data/",
- "build": "npm run create-dirs && npm run build-js && npm run distribute && npm run build-data-files && npm run build-extensions",
+ "build": "npm run create-dirs && npm run build-assets && npm run build-js && npm run distribute && npm run build-data-files && npm run build-extensions",
"clean": "rm -rf firefox/data chrome/data node_modules/ build/"
},
"repository": {
diff --git a/src/image-decoder.js b/src/image-decoder.js
index 7eed765..02ed8ce 100644
--- a/src/image-decoder.js
+++ b/src/image-decoder.js
@@ -1,3 +1,15 @@
-window.image_decoder = {
- "remember" : "https://dujrsrsgsd3nh.cloudfront.net/img/emoticons/23362/noot-1438871175.png"
-}
\ No newline at end of file
+function inject_image(ident, classes) {
+ classes = classes || "";
+ $(ident).each(function() {
+ for (var i = 0; i < image_decoder.length; i++) {
+ key = Object.keys(image_decoder[i]);
+ image = image_decoder[key];
+ $(this).html($(this).html().replace(
+ key,
+ ""
+ ));
+ }
+ });
+}
+
+var image_decoder = %image_decoder%
\ No newline at end of file
diff --git a/src/injections/facebook.js b/src/injections/facebook.js
index 5dbda30..d7370b3 100644
--- a/src/injections/facebook.js
+++ b/src/injections/facebook.js
@@ -1,7 +1,8 @@
-var jq = jQuery.noConflict(true);
+
function change_chat_tabs() {
console.log("Event");
+ inject_image('._d97');
jq('._d97').each(function(){
for (var i = 0; i < image_decoder.length; i++) {
console.log('Checking for ' + image_decoder[i][0])
@@ -39,5 +40,4 @@ jq('._552m').on('input paste', function() { // Text change in textbox. Mainly u
});
-change_chat_tabs();
-alert("Facebook");
\ No newline at end of file
+change_chat_tabs();
\ No newline at end of file
diff --git a/src/injections/github.js b/src/injections/github.js
index 41d235b..44b9c17 100644
--- a/src/injections/github.js
+++ b/src/injections/github.js
@@ -1,37 +1,11 @@
-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() {
- 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,
- ""
- ));
- }
- });
+ inject_image('.comment-body');
}
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,
- ""
- ));
- }
+ inject_image('.comment-body');
}
@@ -46,11 +20,5 @@ jq('.js-comment-container').on('load change', function(){ // when another comme
});
-window.setInterval(function(){
- change_comments();
- change_readme();
-}, 3000);
-
-
-
-alert("Github");
\ No newline at end of file
+change_comments();
+change_readme();
\ No newline at end of file