Last active
August 18, 2017 17:34
-
-
Save saade/42427e8eee91da13ec43cfaf88060003 to your computer and use it in GitHub Desktop.
TUGO - Bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| window.addEventListener('load', () => { | |
| function TUGO_sendMessage(number, message) { | |
| // Add Number | |
| var _number_input = angular.element($(".host")[0]).scope(); | |
| _number_input.tagList.addText(number); | |
| // Add Text | |
| var _text_input = angular.element($('textarea[ng-model="message"]')[0]).scope(); | |
| _text_input.message = message; | |
| _text_input.sendMessage(_text_input.message); | |
| setTimeout(() => { | |
| TUGO_deleteEntries(number); | |
| TUGO_closeDropdown(); | |
| }, 2000); | |
| } | |
| function TUGO_deleteEntries(number) { | |
| var _entries = angular.element($('div[conversation-id="phone:' + number + '"]')[0]).scope(); | |
| _entries.$parent.deleteEntries = _entries.$parent.entries; | |
| _entries.$parent.delete(); | |
| setTimeout(() => { | |
| _entries.$parent.minimize(); | |
| }, 500); | |
| } | |
| function TUGO_formatMessages(_messages_content) { | |
| return _messages_content.entries.map((el) => { | |
| return { | |
| "body": el.content, | |
| "dateTime": el.dateTime, | |
| "sendState": el.sendState, | |
| "type": el.type, | |
| "read": true, | |
| "from": { | |
| "formatted": el.from.formatted, | |
| "id": el.from.id, | |
| "region": el.from.region, | |
| "kind": el.from.kind, | |
| "target": el.from.target | |
| }, | |
| "to": { | |
| "formatted": el.to.formatted, | |
| "id": el.to.id, | |
| "region": el.to.region, | |
| "kind": el.to.kind, | |
| "target": el.to.target | |
| } | |
| } | |
| }); | |
| } | |
| function TUGO_hasSummaries() { | |
| return $('.summary .summary-item').length > 0; | |
| } | |
| function TUGO_getSummaries() { | |
| var _summaries_content = $('.summary .summary-item')[0]; | |
| var _phone = $(_summaries_content).data("qa-phone"); | |
| _summaries_content.click(); | |
| var _messages = $('div[conversation-id="phone:' + _phone + '"]'); | |
| var _messages_angular = angular.element(_messages).scope(); | |
| _messages_angular = _messages_angular.$parent; | |
| setTimeout(() => { | |
| TUGO_deleteEntries(_phone); | |
| _messages.find(".minimize-icon").click(); | |
| }, 1500); | |
| return TUGO_formatMessages(_messages_angular); | |
| } | |
| function TUGO_toggleDropdown() { | |
| var _message_composer = angular.element($(".new-message-composer")[0]).scope(); | |
| _message_composer.onToolbarButton(); | |
| _message_composer.status.isopen = !_message_composer.status.isopen; | |
| } | |
| function TUGO_login(number, password) { | |
| var login = angular.element($('.main-button')[0]).scope(); | |
| login.loginData.number = number; | |
| login.loginData.password = password; | |
| $("input[name='phoneInfo']").val(number); | |
| $("input[name='password']").val(password); | |
| setTimeout(() => { | |
| $(".main-button").click() | |
| }, 500) | |
| } | |
| function TUGO_checkSession() { | |
| return !window.location.href.indexOf("session-expired") > 0 | |
| } | |
| function TUGO_go(url) { | |
| window.location.href = url; | |
| } | |
| // Close mic modal | |
| if ($("e2eOkBtn")) $("e2eOkBtn").click(); | |
| // Bypass notifications | |
| var Notification = { | |
| requestPermission: function() { | |
| console.warn("Bypassed reqeust notification!") | |
| } | |
| } | |
| // Remove animations | |
| $(".dropdown-animation").removeClass("dropdown-animation"); | |
| // Add some function | |
| jQuery.fn.some = function(fn, thisArg) { | |
| var result; | |
| for (var i = 0, iLen = this.length; i < iLen; i++) { | |
| if (this.hasOwnProperty(i)) { | |
| if (typeof thisArg == 'undefined') { | |
| result = fn(this[i], i, this); | |
| } else { | |
| result = fn.call(thisArg, this[i], i, this); | |
| } | |
| if (result) return true; | |
| } | |
| } | |
| return false; | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment