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
|
||||
from base64 import b64encode
|
||||
import json
|
||||
from glob import glob
|
||||
|
||||
def get_filename(path):
|
||||
|
@ -11,9 +10,11 @@ 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_bin.append({ get_filename(filename):
|
||||
"data:image/png;base64," + (open(filename, 'rb').read().encode('base64').replace('\n', ''))
|
||||
})
|
||||
|
||||
image_decoder = {"images":image_bin}
|
||||
|
||||
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({
|
||||
include: site,
|
||||
contentScriptFile: './injections/' + script,
|
||||
attachTo: ['top', 'existing', 'iframe'],
|
||||
attachTo: ['top', 'existing', 'frame'],
|
||||
});
|
||||
}
|
|
@ -9,6 +9,7 @@
|
|||
"build-firefox": "cd firefox/ && jpm xpi && cd -",
|
||||
"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": "npm run build-assets && npm run build-js && npm run distribute && npm run test-firefox",
|
||||
"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",
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
function inject_image(ident, classes) {
|
||||
console.log("Injecting Images in to " + ident);
|
||||
classes = classes || "";
|
||||
$(ident).each(function() {
|
||||
for (var i = 0; i < image_decoder.length; i++) {
|
||||
key = Object.keys(image_decoder[i]);
|
||||
image = image_decoder[key];
|
||||
decoder = image_decoder.images;
|
||||
for (var i = 0; i < decoder.length; i++) {
|
||||
key = Object.keys(decoder[i]);
|
||||
image = decoder[i][key];
|
||||
key = "(" + key + ")";
|
||||
$(this).html($(this).html().replace(key,
|
||||
"<img class='" + classes + "' style='height: 30px; width: 30px;' src='" + image + "'/>"
|
||||
));
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
function change_comments() {
|
||||
console.log("comment event");
|
||||
inject_image('.comment-body');
|
||||
}
|
||||
|
||||
function change_readme() {
|
||||
console.log("readme event");
|
||||
inject_image('#readme');
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue