How to Delete Facebook Messages via Facebook API? - facebook

Is there a way to retrieve all Facebook Message ids with the read mailbox permission and then delete them all one by one? Everyone is crying about how it's difficult to delete your chat/message history. I wondered if there was an easy way to write an app to do this.
Facebook API - Message

Normally you would issue an HTTP DELETE call to https://graph.facebook.com/messageID?access_token=... But it appears that this is an API call that either require special whitelisting from Facebook or isn't currently supported because it does not work right now and returns "Unsupported delete request."

Install https://chrome.google.com/webstore/detail/jquerify/gbmifchmngifmadobkcpijhhldeeelkc
Open the facebook using
https://mbasic.facebook.com/messages/?_rdr
Enable jQuery using jQueryify extension you installed.
Then go to your chrome developer tools> sources > snippet and create a new snippet and paste the following code and run it.
// Code snippet for facebook messages removing:
var WHITELISTED_USERS_X = [];
function removeElement(elementId) {
// Removes an element from the document
var element = document.getElementById(elementId);
if (element) {
element.parentNode.removeChild(element);
}
}
function addElement(parentId, elementTag, elementId, html) {
// Adds an element to the document
// removeElement
removeElement(elementId);
var p = document.getElementById(parentId);
var newElement = document.createElement(elementTag);
newElement.setAttribute('id', elementId);
newElement.innerHTML = html;
if (p) {
p.appendChild(newElement);
} else {
var body = document.getElementsByTagName("body")[0]
body.appendChild(newElement);
}
}
addElement("body", "div", "123x", "hello World23");
console.log(`getOlderMessagesLink()`);
console.log(getOlderMessagesLink());
var aLinks = document.querySelectorAll('h3 a'), i;
for (i = 0; i < aLinks.length; ++i) {
let currentLink = aLinks[i];
currentLink.style.color = currentLink.style.color == "black" ? "red" : "green";
$.get( currentLink.href, function( data ) {
getPayload1(currentLink.href).then(payLoad=>{
let abLink = currentLink.href;
let deleteApiLink = abLink.split('?').pop().split('&');
deleteApiLink.splice(1 , 0, `tids=${deleteApiLink[0].split('=').pop()}`)
deleteApiLink = deleteApiLink.join("&").split("#").shift();
const apiLink = `https://mbasic.facebook.com/messages/action_redirect?` + deleteApiLink;
$.post(apiLink, payLoad ).done(function( data ) {
let mydeletehref = findInParsed(data, "a:contains('Delete')");
const username = currentLink.innerText;
const deleteLink = mydeletehref.href;
if(WHITELISTED_USERS_X.indexOf(username) == -1){
// console.log(`${username}: ${deleteLink}`);
insertDeleteLinkInUser(username, deleteLink);
}
});
});
})
}
function getPayload1(link){
return new Promise(resp=>{
$.get(link, function( html1 ) {
let fbDtsg = findInParsed(html1, "input[name='fb_dtsg']");
let jazoest = findInParsed(html1, "input[name='jazoest']");
resp ({
"fb_dtsg": fbDtsg.value,
"jazoest": jazoest.value,
"delete": "Delete"
})
});
})
}
function findInParsed(html, selector){
return $(selector, html).get(0) || $(html).filter(selector).get(0);
}
function getOlderMessagesLink(html = false){
if(html){
return $("#see_older_threads").find("a").get(0).href;
}
let selector = "#see_older_threads";
return $(selector, html).find("a").get(0).href || $(html).filter(selector).find("a").get(0).href;
}
function insertDeleteLinkInUser(username, link){
$("a:contains('" + username + "')").parent().parent().parent().prepend('DELETE ME');
}

Related

Google Apps Script Error Exception: Questions cannot have duplicate choice values

keep getting this annoying error, tried making a new sheet and new form and issue is repeating itself
Nov 8, 2022, 1:08:30 PM Error Exception: Questions cannot have duplicate choice values.
at [unknown function](Code:21:27)
at [unknown function](Code:11:30)
at populateQuestions(Code:10:14)
at openForm(Code:3:3)
The script used from YouTube link
function openForm(e)
{
populateQuestions();
}
function populateQuestions() {
var form = FormApp.getActiveForm();
var googleSheetsQuestions = getQuestionValues();
var itemsArray = form.getItems();
itemsArray.forEach(function(item){
googleSheetsQuestions[0].forEach(function(header_value, header_index) {
if(header_value == item.getTitle())
{
var choiceArray = [];
for(j = 1; j < googleSheetsQuestions.length; j++)
{
(googleSheetsQuestions[j][header_index] != '') ? choiceArray.push(googleSheetsQuestions[j][header_index]) : null;
}
//item.asMultipleChoiceItem().setChoiceValues(choiceArray);
// If using Dropdown Questions use line below instead of line above.
item.asListItem().setChoiceValues(choiceArray);
}
});
});
}
function getQuestionValues() {
var ss= SpreadsheetApp.openById('1jVxeFFi8LxHGUJ2L3suzjf9iokZN2RI5Vu1hcGCOWrc');
var questionSheet = ss.getSheetByName('Static');
var returnData = questionSheet.getDataRange().getValues();
return returnData;
}
tried to follow the tutorial https://www.youtube.com/watch?v=PRJ4bKk9JE8&t=268s

Prevent submitting a form

I am making a DB of words. And before submitting a new word I want to check if entered word already exists in my DB. For that, I added e.preventDefault() but somehow it does not prevent the form and submitted with the same word that I already have (though the message is displayed correctly)
let bannedWords = <?php echo json_encode($bannedwords); ?>;
$('#submitAddedWord').submit(function (e) {
e.preventDefault();
for (let i = 0; i < bannedWords.length; i++) {
let word = document.querySelector('#word').value;
let message = document.createElement('p');
if(bannedWords[i].word === word) {
message.innerHTML = 'Oooops, this word already exists';
message.style.color = 'red';
document.querySelector('.form-group').append(message);
// setTimeout(function() {message.innerHTML = ''},1500);
} else {
$(this).unbind('submit').submit();
}
}
});`

Word web addin load whole document from server header/footer

We are trying to load a word document from server using JavaScript. We send the document using a base64 encoding. With our current approach, only the body is loading using the function:
context.document.body.insertFileFromBase64(fileContent, "replace");
Unfortunately, the header and the footer are not loading. Is there another approach to load the whole document including body and footer?
the insertFile operation does not overwrite existing header/footers in the document.
According to my research, I saw this article for using insertFileFromBase64.The article says," if you use insertFileFromBase64 to insert the file it does have this blank page with header and footer." Did you have the same issue for this?
However, another article says it's a design issue. Userform will encode data and will create an appointment on Microsoft Outlook Calendar
The article provides approach:
function getFile(){
Office.context.document.getFileAsync(Office.FileType.Compressed, { sliceSize: 4194304 /*64 KB*/ },
function (result) {
if (result.status == "succeeded") {
// If the getFileAsync call succeeded, then
// result.value will return a valid File Object.
var myFile = result.value;
var sliceCount = myFile.sliceCount;
var slicesReceived = 0, gotAllSlices = true, docdataSlices = [];
console.log("File size:" + myFile.size + " #Slices: " + sliceCount);
// Get the file slices.
getSliceAsync(myFile, 0, sliceCount, gotAllSlices, docdataSlices, slicesReceived);
}
else {
app.showNotification("Error:", result.error.message);
}
});
}
function getSliceAsync(file, nextSlice, sliceCount, gotAllSlices, docdataSlices, slicesReceived) {
file.getSliceAsync(nextSlice, function (sliceResult) {
if (sliceResult.status == "succeeded") {
if (!gotAllSlices) { // Failed to get all slices, no need to continue.
return;
}
// Got one slice, store it in a temporary array.
// (Or you can do something else, such as
// send it to a third-party server.)
docdataSlices[sliceResult.value.index] = sliceResult.value.data;
if (++slicesReceived == sliceCount) {
// All slices have been received.
file.closeAsync();
onGotAllSlices(docdataSlices);
}
else {
getSliceAsync(file, ++nextSlice, sliceCount, gotAllSlices, docdataSlices, slicesReceived);
}
}
else {
gotAllSlices = false;
file.closeAsync();
console.log("getSliceAsync Error:", sliceResult.error.message);
}
});
}
function onGotAllSlices(docdataSlices) {
var docdata = [];
for (var i = 0; i < docdataSlices.length; i++) {
docdata = docdata.concat(docdataSlices[i]);
}
var fileContent = new String();
for (var j = 0; j < docdata.length; j++) {
fileContent += String.fromCharCode(docdata[j]);
}
var mybase64 = window.btoa(fileContent);
console.log("here is the base 64", mybase64);
// Now all the file content is stored in 'fileContent' variable,
// you can do something with it, such as print, fax...
}

Perform auto-search in ionic with MongoDB as backend

The search should be based on the first name and last name. During entering the letters the middle letters from the word should not come. It should come only only from the first name and last name. I got the auto-complete code from code pen and Github but as per requirement I need auto search;
Like:
Auto Search
You should look at creating your own custom directive or using an existing one like this https://github.com/guylabs/ion-autocomplete
This is my code snippet for auto-complete which I used but I need First name and last name Search (It should not search random letters) -
var airlines = [{"fs":"LCI","iata":"LF","icao":"LCI","name":"Lao Central Airlines ","active":true},{"fs":"TGU","iata":"5U","icao":"TGU","name":"TAG","active":true},{"fs":"BT","iata":"BT","icao":"BTI","name":"Air Baltic","active":true},{"fs":"9J","iata":"9J","icao":"DAN","name":"Dana Airlines","active":true},{"fs":"2O","iata":"2O","icao":"RNE","name":"Island Air Service","active":true},{"fs":"NPT","icao":"NPT","name":"Atlantic Airlines","active":true},{"fs":"C8","iata":"C8","icao":"ICV","name":"Cargolux Italia","active":true},{"fs":"FK","iata":"FK","icao":"WTA","name":"Africa West","active":true},{"fs":"8K","iata":"8K","icao":"EVS","name":"EVAS Air Charters","active":true},{"fs":"W8","iata":"W8","icao":"CJT","name":"Cargojet","active":true},{"fs":"JBW","iata":"3J","icao":"JBW","name":"Jubba Airways (Kenya)","active":true},{"fs":"TNU","iata":"M8","icao":"TNU","name":"TransNusa","active":true},{"fs":"HCC","iata":"HC","icao":"HCC","name":"Holidays Czech Airlines","active":true},{"fs":"APJ","iata":"MM","icao":"APJ","name":"Peach Aviation","active":true},{"fs":"TUY","iata":"L4","icao":"TUY","name":"LTA","active":true},{"fs":"LAE","iata":"L7","icao":"LAE","name":"LANCO","active":true},{"fs":"L5*","iata":"L5","icao":"LTR","name":"Lufttransport","active":true},{"fs":"QA","iata":"QA","icao":"CIM","name":"Cimber","active":true},{"fs":"KBZ","iata":"K7","icao":"KBZ","name":"Air KBZ","active":true},{"fs":"L2","iata":"L2","icao":"LYC","name":"Lynden Air Cargo","active":true},{"fs":"MPK","iata":"I6","icao":"MPK","name":"Air Indus","active":true},{"fs":"CAO","icao":"CAO","name":"Air China Cargo ","active":true},{"fs":"BEK","iata":"Z9","icao":"BEK","name":"Bek Air","active":true},{"fs":"IAE","iata":"IO","icao":"IAE","name":"IrAero","active":true},{"fs":"GL*","iata":"GL","name":"Airglow Aviation Services","active":true},{"fs":"ATN","iata":"8C","icao":"ATN","name":"ATI","active":true},{"fs":"GU","iata":"GU","icao":"GUG","name":"Aviateca Guatemala","active":true},{"fs":"GHY","icao":"GHY","name":"German Sky Airlines ","active":true},{"fs":"SS","iata":"SS","icao":"CRL","name":"Corsair","active":true},{"fs":"XK","iata":"XK","icao":"CCM","name":"Air Corsica","active":true},{"fs":"W9*","iata":"W9","icao":"JAB","name":"Air Bagan","active":true},{"fs":"Z8*","iata":"Z8","icao":"AZN","name":"Amaszonas","active":true},{"fs":"D2","iata":"D2","icao":"SSF","name":"Severstal Aircompany","active":true},{"fs":"SNC","iata":"2Q","icao":"SNC","name":"Air Cargo Carriers","active":true},{"fs":"PST","iata":"7P","icao":"PST","name":"Air Panama","active":true},{"fs":"VV","iata":"VV","icao":"AEW","name":"Aerosvit Airlines","active":true},{"fs":"UJ","iata":"UJ","icao":"LMU","name":"AlMasria","active":true},{"fs":"9U","iata":"9U","icao":"MLD","name":"Air Moldova","active":true},{"fs":"NF","iata":"NF","icao":"AVN","name":"Air Vanuatu","phoneNumber":"678 238 48","active":true},{"fs":"NJS","iata":"NC","icao":"NJS","name":"Cobham Aviation","active":true}];
airlines = airlines.sort(function(a, b) {
var airlineA = a.name.to();
var airlineB = b.name.toLowerCase();
if(airlineA > airlineB) return 1;
if(airlineA < airlineB) return -1;
return 0;
});
console.log(airlines);
angular.module('ionicApp', ['ionic'])
.factory('FlightDataService', function($q, $timeout) {
var searchAirlines = function(searchFilter) {
console.log('Searching airlines for ' + searchFilter);
var deferred = $q.defer();
var matches = airlines.filter( function(airline) {
if(airline.name.toLowerCase().indexOf(searchFilter.toLowerCase()) !== -1 ) return true;
})
$timeout( function(){
deferred.resolve( matches );
}, 100);
return deferred.promise;
};
return {
searchAirlines : searchAirlines
}
})
.controller('MyCtrl', ['$scope', 'FlightDataService', function($scope, FlightDataService) {
$scope.myTitle = 'Auto Complete Example';
$scope.data = { "airlines" : [], "search" : '' };
$scope.search = function() {
FlightDataService.searchAirlines($scope.data.search).then(
function(matches) {
$scope.data.airlines = matches;
}
)
}
}]);

Inserting current date into confluence hyperlink

I am using this code to display current date in the confluence page.
{run-now:dateFormat =d-MMM-yyyy}
$current_time
{run-now}
My purpose, to include this date into email hyperlink, like below
[Click me|mailto: some_email#domen.com &subject=Update as of - {run-now:dateFormat =d-MMM-yyyy} $current_time{run-now}]
My expectations, is that it will show mailto link after clicking which, it will open email with subject that is including current date.
But this is working unexpectedly
it shows me something like this instead of the link
function run_moreDisplayToggle_1() { // toggle display of "more" rows of parameter table on or of //alert("test"); var table = document.getElementById("run_table_1"); var rows = table.getElementsByTagName("tr"); var isMoreFound = false; for (var i = 0; i < rows.length; i++) { var row = rows.item(i); if (row.id.match("1_row_")) { if (row.style.display == "none") { row.style.display = ""; isMoreFound = true; } else { row.style.display = "none"; } } } var icon = document.getElementById("run_1_advanced_toggle"); var moreElement = document.getElementById("run_1__more") if (isMoreFound) { icon.src = "/images/icons/subtract_12.gif"; icon.title = "Less"; moreElement.value = "true"; } else { icon.src = "/images/icons/add_12.gif"; icon.title = "More"; moreElement.value = "false"; } }
29-Jan-2014" class="external-link" rel="nofollow">Click me
It's better you use HTML Macro to hyperlink your email.
I think it should be something like this:
{html}<a mailto: some_email#domen.com &subject=Update as of - {run-now:dateFormat =d-MMM-yyyy} $current_time{run-now}/a>{html}
Anyway as the confluence expertise always online in Answers I recommend you to check there.