From f4fb7baaa7836897c2ad881b4351f4b28b406624 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 20 Aug 2015 22:38:11 +0100 Subject: [PATCH] Started to fix import bugs --- build-js.sh | 2 +- firefox/index.js | 10 +++++++--- src/image-lookup.js | 2 +- src/injections/facebook.js | 10 ++++++++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/build-js.sh b/build-js.sh index 2c143f8..a1a4c4c 100644 --- a/build-js.sh +++ b/build-js.sh @@ -1,4 +1,4 @@ -#~!/usr/bin/bash +#!/usr/bin/bash cp -r src/* build/ rm -rf build/injections/* diff --git a/firefox/index.js b/firefox/index.js index 8b60a4a..5ca732f 100644 --- a/firefox/index.js +++ b/firefox/index.js @@ -1,10 +1,14 @@ var self = require('sdk/self'); var pageMod = require("sdk/page-mod"); -var sites = require("data/site-decoder.json") +var sites = require("data/site-decoder.json").sites; for (var i = 0; i < sites.length; i++) { + pattern = Object.keys(sites[i])[0]; + script = sites[i][pattern]; + console.log('script ' + script); + console.log('pattern ' + pattern); pageMod.PageMod({ - include: sites[i][0], - contentScriptFile: ["lib/jquery.js", "./image_lookup.js", "injections/" + sites[i][1]] + include: pattern, + contentScriptFile: ["lib/jquery.js", "./image_lookup.js", "injections/" + script] }); } \ No newline at end of file diff --git a/src/image-lookup.js b/src/image-lookup.js index 7332154..09f883e 100644 --- a/src/image-lookup.js +++ b/src/image-lookup.js @@ -1,4 +1,4 @@ var image_decoder = { // Image tag (no brackets) : Image URL - "noot" : "" + "noot" : "https://dujrsrsgsd3nh.cloudfront.net/img/emoticons/23362/noot-1438871175.png" } \ No newline at end of file diff --git a/src/injections/facebook.js b/src/injections/facebook.js index 80274e6..64de20f 100644 --- a/src/injections/facebook.js +++ b/src/injections/facebook.js @@ -1,7 +1,8 @@ function change_chat_tabs() { $('._d97').each(function(){ for (var i = 0; i < image_decoder.length; i++) { - $(this).html($(this).html().replace(image_decoder[i][0], + console.log('Checking for ' + image_decoder[i][0]) + $(this).html($(this).html().replace("(" + image_decoder[i][0] + ")", "" )); } @@ -12,4 +13,9 @@ function change_chat_tabs() { $('.fbNubFlyout').on( 'DOMNodeInserted DOMNodeRemoved change load', function(event) { change_chat_tabs(); -}); \ No newline at end of file +}); + +$('._d97').on('change load', function(event){ + change_chat_tabs(); +}); +alert("Injected"); \ No newline at end of file