From 29161fc565f1e3ef555782aa2755fdb334c10953 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 24 Aug 2015 17:54:23 +0100 Subject: [PATCH] Added images locally, and modified build process --- assets/allthethings.png | Bin 0 -> 3224 bytes assets/build-assets.py | 25 +++++++++++++++++++++++ assets/noot.png | Bin 0 -> 5363 bytes build-js.sh | 6 ++++-- firefox/index.js | 27 ++++++++++--------------- firefox/injector.js | 18 ----------------- firefox/package.json | 18 ++++++++--------- package.json | 3 ++- src/image-decoder.js | 18 ++++++++++++++--- src/injections/facebook.js | 6 +++--- src/injections/github.js | 40 ++++--------------------------------- 11 files changed, 72 insertions(+), 89 deletions(-) create mode 100644 assets/allthethings.png create mode 100644 assets/build-assets.py create mode 100644 assets/noot.png delete mode 100644 firefox/injector.js diff --git a/assets/allthethings.png b/assets/allthethings.png new file mode 100644 index 0000000000000000000000000000000000000000..6243a183546d905c7ac555f502746d7731e5dec3 GIT binary patch literal 3224 zcmV;J3}^F+P)a1vjh7m=#YA&Ei6>ra(zLp~pt!WTnr0>KIUyR8Y6GUR)l)60 z(Ik@40AjfWw2GjzP++(WGhBwt%&H7_-D1Igw00Gbdg!rF%hd}tQUHt*s`zz1=JRH9Kwqsy{UUqIv)W{>7AgVmN>>^!2;Y*jS4{{_z+9Jv^QP zNU4#gseV8vNXaB6aQMjEGCX_&7ZrV?w_3*_A;IGL0fzegivfPl0rdF)Hoy<6j{pfx zYhp#2i1M;xYHn^2fSt<9523i|He0Prd03E%E#smQ899>9pD&;jCr)udfQN{P7cWlL zdAuGqE%gBp`Iu<;=UM|`_Jd$Q8`?d97y$VJX#lzbs9=sDA|oDpD2bbGK8+0Y4`A=U zr{QrAKqx|lhEBoEwE5V-|Cdlz!G{kY;h+C}t1uW?YMM5}W@}AZv}pck{~&5+*LP;5 zKL`MSM-O^GcpXYhi)iM|MGPd1#6*X6?%Z)H7R!AxSFW^PJ9_lfd}j6-jS9uZS-7vS zf4IqHy050Du72M96xJzXbVNjCtkc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WqqN0){g3W z>6Dlj=MnlDEM-e*=!i=Id+c@x1qGSV+v{SFSA$8@A;`saGPsOkR$@xOc(yXNZ}bQ$ zyevS(QUl~YwgIHMNL6wozkX4CGtEq-klXEqaq%>4>71(S2B4gs)_$7U;u#0#CnYNhRhPaLvGNpgAE2jS&+b`0{pmVx}=*$IIjEYw!gcKl@BTn zFE?Mm-PP3CZ1Z&W>I2gzaoxER&im*%E?z8y5E5_X{2ry_JczK}!kfW+>8-$(_?w~e zFLtF5fcRGPGz14M1PG%COo{%K5dim~9rZiHU?heU%#mY6u{u%0>l(8?tm-R`NxWf8 zoCRTOOfuC9v)V0Hp#$9)jgpc|0Kmn9bNJO`+Y#3jB<$pp4xM}9VaM`MW3>=ws6^l8 z2MmG^uq{2t6ADD{th< z)<6q&8%M&`KhzB1PEpZHU>H!;jBF?aWGeyhaQ+>-|b(y!_lA zR2&DAn!{+JEgBJ;InKm7pHA_w2K#&{Q8;`p&0y0vXi+shu`e4hj7-Myi9PB>1-b*H z>i_h0f5`4QL*L^MRYY#zUkF~!<-(x~OrMdAhaXvjjEWG9`pk+sYMM;O8icFn`vas7 z_+ABlizEC$v{CC+<|nqx0000bbVXQnWMOn=I%9HWVRU5xGB7bTEio`HGBZ>#Fgi3a zIx{vaFfckWFyqaV=KufzC3HntbYx+4WjbwdWNBu305UK!G%YbOEiyAyFfckaFgi0f zD=;uRFffvkDq8>m02y>eSaefwW^{L9a%BKPWN%_+AW3auXJt}lVPtu6$z?nM0000< KMNUMnLSTZN8z43S literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..024c89f46f64a12ff694ecfd83ce1d4915aaecd2 GIT binary patch literal 5363 zcmZ{HWmMFU^Yv$uSh`yYS&$A{x|eRggd!o0bayV&EFmGGfOJc(lyo;pNvFEN3P^YS z`MrEzJZH|#J!fX_nRDjN+=B10jeft8k6d*r>hD>%ZrmQQb;Q4z> zS_=2BDbf#h&*LKH>MlV3VD?`d?85qM#A|fHNL0Is>v>K4x!Aj$f7!v(fRcHw!l%dz zkhL1+aSXsHDa_08!uJWDK2z8exNIg5e(Y%y2C#8+bh!6ey~M!W7Ks7=w^ zP#x-#-*^Co04PE9Ey92z65yo=|Uf^3P*+eLnmqE){Ep0E>ZiBOD+3vOdj2(wL1T&i%6t z!_hkL?TN1jg5(9_k7c<|ys~;<3zV4uT` zby`QT_cC~yYIoqQdl_4(nM9W9Wzm_qRsfK!u3;(t8O z9;N{Sa4=K{OV}=4nkF1;0nXA4m+%W?9E;M4c`s@Rz*HhNKFITOM;hp0veuF|!YKEm zjLM>wL@{{WFeZAinla`#s3hTUY2e%Zc&_G8X{FTf#G+|BPYjQM6?aQQ;>G z>tl{p!F#TlHl%AUr29UN#bD@d5yKUOSYoy!FSFE;R1q<)Qi!~C9?gjCVi|)&)Kb35 zEIlEt@W+)M-gof0GX4~y9jj3|1MKq@a)+~s}rswZw))MWLXHri0yj5fl2>fg82h~1`~w)Irob+vI;N`cszorhY-eS zk#?9h1VNL1jdf9w7D&&8jj>XZa>aP}S@oUt8TWy<=*eRHn6pw%RKkixb?NMJ%hSH4 z&MJt@qnXcA2ZpTcg%>~V$q}*Q58-)``b%7qTtTnI{o%KXuu>YGryTcb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|B*kyyCx9F{tT%UuiHQkdhRM1SbrZPBKiS6iGL0U$EPX{T$G;$? zXGgbtuwyNhOXnB-b!TU%Sy*z&CNd>C2{I_Vipy+Xw;;=bg@qFaL^Q7m!Ue##vj0K0 zYTu9$V3l$kc?}jVQ}dEN3z3oXK8COtXA1frO!kVWf_kx^vl2Y@f&m3^S-2a~a~kl1 z>?Ca$AzV-g+`F$<9jEYISKg{OHSht6qns2Jzv$@_KDn*f-yObC8*-=JyPt#kqSBaz z2>bCbW@d_*!Wocl;RVmgWr2DKbf}^sG+Ua|3m)Z)Eup!kC*$=P)Z$ZRa;xOu!vb-r|-Y}wd4?j*I(|bQcL3dYYupo z*-45_I|Ag)i#TV4BofZ?3Y6LVyBPFJ!sy(2F=MP7v%g5@I{UeHHt7~*j*EF(-Gq>Jn|)k+1ue!Zt|J;32_CCyZ)B1CAKQq&== zRluxND22Vdzwxd04bv<(Zixu5|KMO}RaG0*Y3HzhHtqMFEmDjrGfXA4Gf!X6M35x5 z58GjT&~78vvUUZwQ%%ZrL{rcWe@ZL7nwJ9oeu5w-HndK+piN^T5DWW}>r;Jpt|MiC z_yVgluv#+t!)3|fKNiQPc8&;=!<)Mv?<>MwAxGgAT3SEH`Oa#hCtacMF#0Qf!}g4{ zrlTSFX6Gr-mkwIChg8?6QT&rn1wD^(Xy5GS2n|+7`A-OI(5L>nTrYY*yS__nTHfo=HXc#b^DJ~*c&0-^*}ArP)_(Lv^mGdYEQNs{!q~rxBe4XRpzd*h0 zuRV~RswHq*YCBT99ILReP09vNu~fLlv~>d23U+5DwyQk2S!bj3@ z5oZw%ZfGOWPiL>|7;8<^TDI=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