Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localize images (Ref: Issue #2) #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 24 additions & 22 deletions Chrome extension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ $.get( "https://crypter.co.uk/version.php", function( data ) {
actualVersion = data;
});

function preloadimages(arr){
var newimages=[]
var arr=(typeof arr!="object")? [arr] : arr
for (var i=0; i<arr.length; i++){
newimages[i]=new Image()
newimages[i].src=arr[i]
}
// Icons
function getIcon(name) {
return chrome.extension.getURL('images/' + name + '.png');
}
preloadimages(['https://crypter.co.uk/icons/lock_empty.png', 'https://crypter.co.uk/icons/lock_should.png','https://crypter.co.uk/icons/lock_encrypted.png','https://crypter.co.uk/icons/lock_open.png']);
var icon = {
lock_empty: getIcon('lock_empty'),
lock_encrypted: getIcon('lock_encrypted'),
lock_open: getIcon('lock_open'),
lock_should: getIcon('lock_should'),
lock_should_black: getIcon('lock_should_black')
};

function getIndicesOf(searchStr, str) {
//counts how many times searchStr occurs in str
Expand Down Expand Up @@ -177,7 +179,7 @@ function setLockOnChat(){
if (html.indexOf('Add Photos') >= 0 && $(this).parent("span").parent("div").parent("div").html().indexOf("crypter") == -1){
var textarea = $(this).closest( ".fbNubFlyoutFooter" ).find("._5rpu");
textarea.addClass("textA");
$(this).parent("span").after('<span style="cursor:pointer;display:table;" class="_552o"><img style="cursor:pointer;vertical-align:middle;display:table-cell;padding-top: 4px;" class="crypter" src="https://crypter.co.uk/icons/lock_empty.png" height ="15px" /></span>');
$(this).parent("span").after('<span style="cursor:pointer;display:table;" class="_552o"><img style="cursor:pointer;vertical-align:middle;display:table-cell;padding-top: 4px;" class="crypter" src="' + icon.lock_empty + '" height ="15px" /></span>');
}
}
});
Expand Down Expand Up @@ -240,7 +242,7 @@ function setDecryptButton(){

if(hasdecrypted == false){
//set black padlock for message
span.html("<a id='"+crypt+"' class='decrypt'><img style='position:relative; top: 3px;' src='https://crypter.co.uk/icons/lock_should_black.png' height='15px' /></a>");
span.html('<a id="' + crypt + '" class="decrypt"><img style="position:relative; top: 3px;" src="' + icon.lock_should_black + '" height="15px" /></a>');
}
}
}
Expand Down Expand Up @@ -280,19 +282,19 @@ $( document ).on( 'keyup', '.textA', function(e){
&& message.substring(0, tag.length) == tag
&& message.substring(message.length - tag.length, message.length) == tag){
//message is encrypted and formatted
if(crypter.attr("src") != "https://crypter.co.uk/icons/lock_encrypted.png"){
crypter.attr("src","https://crypter.co.uk/icons/lock_encrypted.png");
if(crypter.attr("src") != icon.lock_encrypted){
crypter.attr("src", icon.lock_encrypted);
}
}else if($(this).parents(".fbNubFlyoutInner").find('.crypter').attr("fb_en") == 1 && message.length > 0 && getPass($(this))){
crypter.attr("src","https://crypter.co.uk/icons/lock_encrypted.png");
crypter.attr("src", icon.lock_encrypted);
}else if(message.length > 0 && getPass($(this))){
if(crypter.attr("src") != "https://crypter.co.uk/icons/lock_should.png"){
crypter.attr("src","https://crypter.co.uk/icons/lock_should.png");
if(crypter.attr("src") != icon.lock_should){
crypter.attr("src", icon.lock_should);
}
}else{
//either no password has been set or there is no text in the text area
if(crypter.attr("src") != "https://crypter.co.uk/icons/lock_empty.png"){
crypter.attr("src","https://crypter.co.uk/icons/lock_empty.png");
if(crypter.attr("src") != icon.lock_empty){
crypter.attr("src", icon.lock_empty);
}
}
});
Expand Down Expand Up @@ -371,7 +373,7 @@ $( document ).on( 'click', '.crypter', function(){
var messageContent = bottomBit.find(".textA").text();
if(messageContent.length > 0){
if(getIndicesOf(tag, messageContent).length < 2){
$(this).attr("src","https://crypter.co.uk/icons/lock_encrypted.png");
$(this).attr("src", icon.lock_encrypted);
//encrypt message
var encrypt = tag+CryptoJS.AES.encrypt(messageContent, getPass($(this)))+tag;
//replace text
Expand Down Expand Up @@ -406,17 +408,17 @@ $( document ).on( 'click', '.crypter', function(){
//decrypt-lock hover animation
$(document).on({
mouseenter: function () {
$(this).find("img").attr("src","https://crypter.co.uk/icons/lock_open.png");
$(this).find("img").attr("src", icon.lock_open);
},
mouseleave: function () {
$(this).find("img").attr("src","https://crypter.co.uk/icons/lock_should_black.png");
$(this).find("img").attr("src", icon.lock_should_black);
}
}, ".decrypt");

//encrypt-lock hover fade (emulating facebook)
$(document).on({
mouseenter: function () {
if($(this).attr("src") == "https://crypter.co.uk/icons/lock_empty.png"){
if($(this).attr("src") == icon.lock_empty){
$(this).animate({opacity: 0.5}, 200);
}
},
Expand Down Expand Up @@ -510,4 +512,4 @@ document.addEventListener('keyup', function(evt){
evt.preventDefault();
return false;
}
},true);
},true);
Binary file added Chrome extension/images/lock_empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Chrome extension/images/lock_encrypted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Chrome extension/images/lock_open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Chrome extension/images/lock_should.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Chrome extension/images/lock_should_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions Chrome extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"manifest_version": 2,

"name": "Facebook Chat Encrypter",
"short_name": "Facebook Encrypter",
"description": "A native encryption tool for Facebook messenger.",
"version": "3.1.4.1115",
"icons": { "128": "logo.png" },
"icons": {
"128": "logo.png"
},
"version_name": "1.092 beta",
"content_scripts": [ {
"js": [ "jquery.min.js", "aes.js", "blurbox.js", "background.js" ],
"matches": [ "https://www.facebook.com/*"]
}]
"content_scripts": [{
"matches": ["*://www.facebook.com/*"],
"js": ["jquery.min.js", "aes.js", "blurbox.js", "background.js"]
}],
"web_accessible_resources": ["images/*.png"]
}