Skip to content

Commit

Permalink
#42. replaced textArea with fast ace editor; added status badge and i…
Browse files Browse the repository at this point in the history
…nformation message
  • Loading branch information
vanchope committed Feb 13, 2018
1 parent 322a217 commit bfb27d2
Show file tree
Hide file tree
Showing 17 changed files with 196 additions and 107 deletions.
9 changes: 9 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
###Release Notes

February 12, 2018 --- Version 2.2.4
* Added @username for users and groups
* html usernames displayed as text


February 5, 2018 --- Version 2.2.3
???


February 5, 2018 --- Version 2.2.2
* Fixed bug when a chat contains phone calls

Expand Down
3 changes: 0 additions & 3 deletions background.html

This file was deleted.

24 changes: 24 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var aceTopScroll = 0
var aceCurRow = 0
var Status // 'working' or 'ready'
var last_request_time

function bg_notify(status){
Status = status
var badge = ''
if (status && status=='working')
badge = '!'
chrome.browserAction.setBadgeText({text: badge})
}

chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.runtime.onMessage.addListener(function(msg) {
if (msg.detail.status){
bg_notify(msg.detail.status)
}else{
var popups = chrome.extension.getViews({type: "popup"});
if (0 < popups.length)
popups[0].displayMessages(msg)
}
})
})
2 changes: 1 addition & 1 deletion content_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ inject_script('inject.js')
console.log("script injected.")

document.addEventListener('from_injected', function(e) {
//console.log("sending message with history to extension");
chrome.runtime.sendMessage({detail: e.detail}, null);
});

Expand All @@ -28,6 +27,7 @@ function scrollUp(){

chrome.runtime.onMessage.addListener(function (request_msg, sender, sendResponse) {
console.log('content script received request '+request_msg.text);
document.dispatchEvent(new CustomEvent('to_injected_status', {}));
if (request_msg.text === 'stch_check_conn') {
sendResponse({text : "OK"})
}
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
32 changes: 30 additions & 2 deletions inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,22 @@ var countMessages
var photo_ids // {'msg_id', 'photo_id'}
var photosData

var Ready

function notify_status(){
document.dispatchEvent(new CustomEvent('from_injected', {
detail:{
status: (Ready ? 'ready':'working'),
}
}))
}

function setReady(ready){
if (Ready != ready){
Ready = ready
notify_status()
}
}

function clear(){
historyForPeerID = 0
Expand All @@ -22,6 +37,7 @@ function clear(){
countMessages = -1
photo_ids = []
photosData = []
setReady(true)
console.log('cleared')
}

Expand Down Expand Up @@ -59,6 +75,7 @@ function sendHistory(){
countPhotos: photosData && photosData.count ? photosData.count : 0,
}
}))
setReady(true)
}

function getPhotosData(AppPhotMng, userID){
Expand All @@ -72,7 +89,7 @@ function getPhotosData(AppPhotMng, userID){
function updateCache_PeerFullName(userID,AppUsrMng){
if (!(userID in peerIDs)){
var userObject = AppUsrMng.getUser(userID)
if (userObject.pFlags.deleted){
if (userObject.deleted || (userObject.pFlags && userObject.pFlags.deleted)){
peerIDs[userID] = 'DELETED'
}else{
peerIDs[userID] = userObject.first_name
Expand Down Expand Up @@ -197,7 +214,7 @@ function processGetHistoryResponse(peerID,res,AppMesMng,AppUsrMng,AppChatsMng,Ap
updateCache_PeerFullName(fwdSender,AppUsrMng)
}
if (msgWrap.media){
console.log('found media type of the message, date = '+msgDate)
console.log('found ' + msgWrap.media._ + ' media type of the message, date = '+msgDate)
switch (msgWrap.media._) {
case 'messageMediaPhoto':
var photoId = msgWrap.media.photo.id
Expand Down Expand Up @@ -289,6 +306,7 @@ function processGetHistoryResponse(peerID,res,AppMesMng,AppUsrMng,AppChatsMng,Ap
}

function handleMoreHistoryRequest(limit){
setReady(false)
var injector = angular.element(document).injector()
var AppMesManager = injector.get('AppMessagesManager')
var AppUsrManager = injector.get('AppUsersManager')
Expand Down Expand Up @@ -338,18 +356,28 @@ function prepare(){

prepare()

document.addEventListener ("to_injected_status", function(e){
notify_status()
}, false);

document.addEventListener ("to_injected_get_more", function(e){
if (!Ready)
return
handleMoreHistoryRequest(e.detail)
}, false);

document.addEventListener ("to_injected_current", function(){
if (!Ready)
return
if (countMessages>=0)
handleCurrentHistoryRequest()
else
handleMoreHistoryRequest(limit1)
}, false);

document.addEventListener ("to_injected_open_photos", function(e){
if (!Ready)
return
var injector = angular.element(document).injector()
var AppPhotManager = injector.get('AppPhotosManager')
if (photo_ids.length > 0){
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions lib/ace-2018.02.11.min.js

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@

"name": "Save Telegram Chat History",
"description": "Dumps your Telegram chat history with an active peer to plaintext.",
"version": "2.2.4",
"version": "2.2.5",
"author": "pigpag.net",
"homepage_url": "https://github.com/pigpagnet/save-telegram-chat-history",

"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
},

"background": {
"page": "background.html"
"scripts": ["background.js"]
},

"browser_action": {
"default_icon": "icon16.png",
"default_icon": "icons/icon16.png",
"default_popup": "popup.html",
"default_title": "Save Telegram Chat History"
},

"content_scripts": [
{
"matches": ["https://web.telegram.org/*"],
"js": ["jquery-1.12.0.min.js", "angular-1.5.8.min.js","jquery.nanoscroller.0.8.7.js", "content_script.js"]
"js": ["lib/jquery-1.12.0.min.js", "lib/angular-1.5.8.min.js","lib/jquery.nanoscroller.0.8.7.js", "content_script.js"]
}
],

Expand Down
2 changes: 1 addition & 1 deletion options.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
background-color: lightgrey;
}
</style>
<script src="jquery-1.12.0.min.js"></script>
<script src="lib/jquery-1.12.0.min.js"></script>
<script src="generic_tools.js"></script>
<script src="options.js"></script>
</head>
Expand Down
18 changes: 10 additions & 8 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,16 @@
}

</style>
<script src="jquery-1.12.0.min.js"></script>
<script src="angular-1.5.8.min.js"></script>
<script src="FileSaver.min_20170301.js"></script>
<script src="lib/ace-2018.02.11.min.js"></script>
<script src="lib/jquery-1.12.0.min.js"></script>
<script src="lib/angular-1.5.8.min.js"></script>
<script src="lib/FileSaver.min_20170301.js"></script>
<script src="generic_tools.js"></script>
<script src="popup.js"></script>
</head>
<body>
<textarea id="myTextarea" ></textarea>
<!-- <textarea id="myTextarea" ></textarea> -->
<div id='myTextarea'></div>
<div class='container separator'>
<table class='tableGrid row_cell row_cell_heigth '>
<tr><td><div class='row_cell'>Load</div></td></tr>
Expand Down Expand Up @@ -101,13 +103,13 @@
<table>
<tr>
<td><div>Cursor photo</div></td>
<td><div class='row_cell'><button class="btnPhoto" id="btnOpenPrevPhoto" type="button" disabled></button></div></td>
<td><div class='row_cell'><button class="btnPhoto" id="btnOpenNextPhoto" type="button" disabled></button></div></td>
<td><div class='row_cell'><button class="btnPhoto" id="btnOpenPrevPhoto" type="button" disabled>prev</button></div></td>
<td><div class='row_cell'><button class="btnPhoto" id="btnOpenNextPhoto" type="button" disabled>next</button></div></td>
</tr>
<tr>

<td><div class='row_cell'><button class="btnPhoto" id="btnOpenPhotos" type="button" disabled></button></div></td>
<td><div class='row_cell'><button class="btnSaveAs" id="btnSaveAs" type="button" disabled></button></div></td>
<td><div class='row_cell'><button class="btnPhoto" id="btnOpenPhotos" type="button" disabled>Open photos</button></div></td>
<td><div class='row_cell'><button class="btnSaveAs" id="btnSaveAs" type="button" disabled>Save As Text</button></div></td>
<td><div class='row_cell'><button class="btnIcon" id="btnClose" type="button" disabled>Close</button></div></td>
</tr>
</table>
Expand Down
Loading

0 comments on commit bfb27d2

Please sign in to comment.