Fixed bug with images and removed debug logs
This commit is contained in:
parent
970122f8f3
commit
d46934cdb9
5 changed files with 14 additions and 11 deletions
|
@ -1,5 +1,4 @@
|
||||||
import json, os
|
import json
|
||||||
from base64 import b64encode
|
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
|
||||||
def get_filename(path):
|
def get_filename(path):
|
||||||
|
@ -11,9 +10,11 @@ image_bin = []
|
||||||
|
|
||||||
for filename in files:
|
for filename in files:
|
||||||
with open(filename, 'rb') as file:
|
with open(filename, 'rb') as file:
|
||||||
image_bin.append({ get_filename(filename): "data:image/png;base64,"+ (str(b64encode(file.read()))[2:-1])})
|
image_bin.append({ get_filename(filename):
|
||||||
|
"data:image/png;base64," + (open(filename, 'rb').read().encode('base64').replace('\n', ''))
|
||||||
image_decoder = {"sites":image_bin}
|
})
|
||||||
|
|
||||||
|
image_decoder = {"images":image_bin}
|
||||||
|
|
||||||
image_decoder_json = json.dumps(image_decoder, indent=2, sort_keys=True)
|
image_decoder_json = json.dumps(image_decoder, indent=2, sort_keys=True)
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,6 @@ for (var i = 0; i < sites.length; i++) {
|
||||||
pageMod.PageMod({
|
pageMod.PageMod({
|
||||||
include: site,
|
include: site,
|
||||||
contentScriptFile: './injections/' + script,
|
contentScriptFile: './injections/' + script,
|
||||||
attachTo: ['top', 'existing', 'iframe'],
|
attachTo: ['top', 'existing', 'frame'],
|
||||||
});
|
});
|
||||||
}
|
}
|
|
@ -9,6 +9,7 @@
|
||||||
"build-firefox": "cd firefox/ && jpm xpi && cd -",
|
"build-firefox": "cd firefox/ && jpm xpi && cd -",
|
||||||
"build-chrome": "crx pack chrome -o chrome/hipchat-emoticons-for-all.crx -p chrome/key.pem",
|
"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 -",
|
"test-firefox": "cd firefox/ && jpm run -b /usr/bin/firefox && cd -",
|
||||||
|
"test": "npm run build-assets && npm run build-js && npm run distribute && npm run test-firefox",
|
||||||
"build-js": "bash build-js.sh",
|
"build-js": "bash build-js.sh",
|
||||||
"build-assets": "python assets/build-assets.py",
|
"build-assets": "python assets/build-assets.py",
|
||||||
"build-data-files": "python firefox/build-package.py && python chrome/build-manifest.py",
|
"build-data-files": "python firefox/build-package.py && python chrome/build-manifest.py",
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
function inject_image(ident, classes) {
|
function inject_image(ident, classes) {
|
||||||
|
console.log("Injecting Images in to " + ident);
|
||||||
classes = classes || "";
|
classes = classes || "";
|
||||||
$(ident).each(function() {
|
$(ident).each(function() {
|
||||||
for (var i = 0; i < image_decoder.length; i++) {
|
decoder = image_decoder.images;
|
||||||
key = Object.keys(image_decoder[i]);
|
for (var i = 0; i < decoder.length; i++) {
|
||||||
image = image_decoder[key];
|
key = Object.keys(decoder[i]);
|
||||||
|
image = decoder[i][key];
|
||||||
|
key = "(" + key + ")";
|
||||||
$(this).html($(this).html().replace(key,
|
$(this).html($(this).html().replace(key,
|
||||||
"<img class='" + classes + "' style='height: 30px; width: 30px;' src='" + image + "'/>"
|
"<img class='" + classes + "' style='height: 30px; width: 30px;' src='" + image + "'/>"
|
||||||
));
|
));
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
function change_comments() {
|
function change_comments() {
|
||||||
console.log("comment event");
|
|
||||||
inject_image('.comment-body');
|
inject_image('.comment-body');
|
||||||
}
|
}
|
||||||
|
|
||||||
function change_readme() {
|
function change_readme() {
|
||||||
console.log("readme event");
|
|
||||||
inject_image('#readme');
|
inject_image('#readme');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue