API Add-on SDK - recently closed tabs and windows - firefox-addon-sdk

Is there a special API for Firefox add-ons that returned recently closed tabs and windows or the only solution is collect their manually ?

No, there isn't one, but both the windows module and the tabs module have a close event, so it's very easy to collect them manually:
var tabs = require("sdk/tabs");
var closedTabs = [];
tabs.on("close", function(tab) {
closedTabs.unshift(tab);
});
var mostRecentlyClosedTab = closedTabs[0];

Related

Export Standard/Extended User Greetings (Exchange 2016) - For Use In XMedius AVST

In an earlier post on June 18, 2018 (my birthday BTW), a user asked "Hopefully a simple question - at one time I know when user's recorded their personal greetings for UM voicemail in o365 (regular greeting and/or extended absence greeting) these were stored in their Exchange inbox using a special item type (i.e. "IPM.Configuration.Um.CustomGreetings.External"). However setting up my test o365 setup, getting UM configured and all that, after recording my personal greeting and going through each item starting from the root of my inbox, (some 900+ items - lots of odd stuff in there) - I don't see anything like this any more. Lots of log, activity items, some messages but nothing about greetings. Extracting everything that could cast to an email type to a folder I went through each one - nothing promising. anyone have any clues where the custom greetings for users UM (not auto attendant recordings - that's a different beast) has gone off to and how to get to it?" After reading through the answers as well as the code that was provided by Jeff Lindborg, I thought that I was getting somewhere. With a lot of trial and error, I was finally able to get the EWS-FAI module installed as well as the Exchange Web Services API. Unfortunately, when it came to running the provided code, this is where I am stumped. I'm not a developer or 'coder' in any form, but I'm always looking for effective and efficient methods to do my work. With that said, I'm trying to run this on a Win10 workstation, but can't seem to figure out which program this needs to run within. I've tried Powershell, but that doesn't work. I have access to the necessary accounts for mailbox impersonation as well as any other permissions needed. I've provided the code that was originally supplied for review. Any additional help would be greatly appreciated.
Code
ExchangeService _service;
_service = new ExchangeService(ExchangeVersion.Exchange2016); // Exchange2013_SP1);
_service.Credentials = new WebCredentials("user#domain", "myPw");
_service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
//select the user you're fetching greetings for
_service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "user#domain");
//get the root folder for the current account
var oParamList = new List<FolderId> {WellKnownFolderName.Root};
var oTemp = _service.BindToFolders(oParamList, PropertySet.FirstClassProperties);
var oRoot = oTemp.First().Folder;
var oView = new ItemView(50)
{
PropertySet = new PropertySet(BasePropertySet.FirstClassProperties),
Traversal = ItemTraversal.Associated
};
SearchFilter oGreetingFilter = new SearchFilter.ContainsSubstring(ItemSchema.ItemClass,
"IPM.Configuration.Um.CustomGreetings", ContainmentMode.Substring, ComparisonMode.IgnoreCase);
var oResults = _service.FindItems(oRoot.Id, oGreetingFilter, oView);
//fetch the binary for the greetings as values
var oPropSet = new PropertySet(BasePropertySet.FirstClassProperties);
var oRoamingBinary = new ExtendedPropertyDefinition(31753, MapiPropertyType.Binary);
oPropSet.Add(oRoamingBinary);
_service.LoadPropertiesForItems(oResults, oPropSet);
var strFileName = "";
foreach (var oItem in oResults.Items)
{
if (oItem.ItemClass.Equals("IPM.Configuration.Um.CustomGreetings.External",
StringComparison.InvariantCultureIgnoreCase))
strFileName = "jlindborg_Standard.wav";
if (oItem.ItemClass.Equals("IPM.Configuration.Um.CustomGreetings.Oof",
StringComparison.InvariantCultureIgnoreCase))
strFileName = "jlindborg_Extended.wav";
File.WriteAllBytes("d:\\" + strFileName, (byte[]) oItem.ExtendedProperties.First().Value);
}
}
The code you posted is c# so you would need to use Visual Studio to create a C# application add a reference to the EWS Managed API and compile that for it to work (you'll need to engage a developer or learn some basic coding).
EWS-FAI is a powershell module it should be able to return that item and you should be able to write that to a file eg something like
$MailboxName = "mailbox#domain.com"
$Item = Get-FAIItem -MailboxName $MailboxName -ConfigItemName Um.CustomGreetings.External -Folder Inbox -ReturnConfigObject
[System.IO.File]::WriteAllBytes(("C:\temp\" + $MailboxName + ".wav"),$Item.BinaryData)

Is it possible to force a copy of a protected Google doc? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
Google docs can “lock” a page so that it’s impossible to copy from its text. This seems wrong to me; shouldn't a computer’s ability to copy and paste be intrinsic? I can’t understand how a webpage can “overstep” its authority and prevent my computer from doing something totally natural. It seems that if I can be served and display text that I should be able to copy it.
How does this webpage prevent my machine from copying?
Here is how to copy (or print) the protected google sheet values.
NOTE: With this technique you can copy the cells from each sheet; it's not possible to duplicate the spreadsheet file itself. Formatting is preserved but formulas are not.
Change the URL to:
https://docs.google.com/spreadsheets/u/1/d/***[document id]***/preview
The document ID is the random string found in the google sheet URL that is normally 40 to 45 characters long.
For each sheet, type Ctrl+A, Ctrl+C
Paste the cells into another spreadsheet. Formatting
As of the 10th of May, 2018, disabling JavaScript will not load the document at all, and changing the 'edit' to 'preview' also no longer works.
I have found that if you click on the three dots and go to:
More Tools > Developer Tools and then click on console, and type in 'document.body.innerText', it loads the entire document as a text file, so that you can copy to your heart's content.
Disable javascript in with developer tools, right click the page, click 'print', change the print destination from your printer to 'save as pdf', and you've got it.
I tried the other options and none worked for me - then, tried downloading webpage and saving link. Re-opened from docs, and then I was able to download as PDF.
EDIT: This doesn't work anymore
I've found out how they're disabling copying, so I'm turning my comment into an answer.
Here's the script that runs on the page that prevents copying:
function rtcScript() {
document.oncontextmenu = null;
document.onselectstart = null;
document.onmousedown = null;
document.onclick = null;
document.oncopy = null;
document.oncut = null;
var elements = document.getElementsByTagName('*');
for (var i = 0; i < elements.length; i++) {
elements[i].oncontextmenu = null;
elements[i].onselectstart = null;
elements[i].onmousedown = null;
elements[i].oncopy = null;
elements[i].oncut = null;
}
function preventShareThis() {
document.getSelection = window.getSelection = function() {
return {isCollapsed: true};
}
}
var scripts = document.getElementsByTagName('script');
for (var i = 0; i < scripts.length; i++) {
if (scripts[i].src.indexOf('w.sharethis.com') > -1) {
preventShareThis();
}
}
if (typeof Tynt != 'undefined') {
Tynt = null;
}
}
rtcScript();
setInterval(rtcScript, 2000);
Notice that it's setting every element to not be copyable, selectable, or cuttable, as well as disabling the context menus. This is trivial to bypass by disabling scripts on the page. See this question for how to do it on Chrome. I've tested this myself - if you disable JavaScript via that method while viewing the locked document, you can immediately begin selecting and copying the text with no issues.

Search on worklist does not work in SAPUI5 Fiori Template Application

Hi SAPUI5 developers,
I made a Firori Worklist project inside of WebIDE. I connected it to an OData server and selected SAPUI version 1.38 as default.
It shows the worklist correctly and I can press on items and move between views and visit the object especially.
So everything seems to work fine.
The only thing that is not working is the search box. Its event is triggered whenever I type something inside it and press enter, but it does not filter anything.
The functions that are called are as follow:
onSearch: function(oEvent) {
if (oEvent.getParameters().refreshButtonPressed) {
// Search field's 'refresh' button has been pressed.
// This is visible if you select any master list item.
// In this case no new search is triggered, we only
// refresh the list binding.
this.onRefresh();
} else {
var oTableSearchState = [];
var sQuery = oEvent.getParameter("query");
if (sQuery && sQuery.length > 0) {
oTableSearchState = [new Filter("ZBrandName", FilterOperator.Contains, sQuery)];
}
this._applySearch(oTableSearchState);
}
},
/**
* Internal helper method to apply both filter and search state together on the list binding
* #param {object} oTableSearchState an array of filters for the search
* #private
*/
_applySearch: function(oTableSearchState) {
var oTable = this.byId("table"),
oViewModel = this.getModel("worklistView");
console.log(oTable);
oTable.getBinding("items").filter(oTableSearchState, "Application");
// changes the noDataText of the list in case there are no filter results
if (oTableSearchState.length !== 0) {
oViewModel.setProperty("/tableNoDataText", this.getResourceBundle().getText("worklistNoDataWithSearchText"));
}
},
Thanks in advance.
var oFilter = new sap.ui.model.Filter(oTableSearchState, true);
oTable.getBinding("items").filter(oFilter, "Application");
The problem that I reported may happen for others also thus I replied to my question because I found the answer.
The story is that when I used NorthWind OData service the Fiori Worklist template of the SAP WebIDE works fine and I could see a list of items and search on them (filter).
But when I used our internal SAP ERP OData Service I could see the list of items but I couldn't filter them.
Thus I thought the problem is related to SAP and it can not update the view.
But in fact, SAPUI5 sends a new request to OData Server for each filtering, while I thought the filtering is something that is done inside of the browser.
Therefore, the problem was related to our OData Service implementation that ignored the request options. While we had to implement whole the functionality of the OData specifications in our OData service.
I hope this info works for other who encounter this problem.

Test if an add-on sdk firefox extension is installed

my question is in the subject.
I need to be able to test if my add-on sdk based extension is installed in order to open it programmatically.
How would I do that ?
Basically, I have a JS script checking for the web browser of the user and if my extension is installed, I'd like to redirect to a specific url, which will launch the opening of the extension.
I read that with XUL extension, adding a contentaccessible=yes to any image and testing it onload gives us the answer, but it seems we can't do that with add-on sdk based...
Any idea ?
Thanks anyway for reading me :)
You should look at the docs for the AddonManager:
https://developer.mozilla.org/en-US/docs/Addons/Add-on_Manager/AddonManager
Here is a code snippet that you coulde use to get going:
const { Cu } = require("chrome");
let AddonManager = Cu.import("resource://gre/modules/AddonManager.jsm").AddonManager;
AddonManager.getAddonsByTypes(["extension"], function(addons) {
var addonData = [];
for (let i in addons) {
let cur = addons[i];
addonData.push({
id: cur.id.toString(),
name: cur.name,
});
};
console.log(JSON.stringify(addonData, null, ' '));
});
I've hosted this code on the Add-on Builder as well:
https://builder.addons.mozilla.org/package/44810/latest/
Edit: Builder is EOL and will go offline in a month.

HTML5 File API in Firefox Addon SDK

Is there a way to access Html5 file api in Fire Fox addon sdk in the content script?
This is needed in order to store user added words and their meanings. The data can grow large and so local storage isn't an option.
window.requestFileSystem3 = window.requestFileSystem || window.webkitRequestFileSystem;
gives me the error TypeError: window.requestFileSystem3 is not a function.
I am asking this because i am porting this code from a Google Chrome Extension which allows accessing the file api in a content script.
Additional Questions
1) If HTML5 File API is not allowed then should i use file module?
2) Does the file module allow access to any file on the file system as opposed to the Html5 file api which only access to a sandboxed access to file system?
3) Assuming i have to use file module what would be the best location to store my files ( like the user profile directory or extension directory ) and how would i get this path in code.
I apologize for so many sub questions inside this questions. Google wasn't very helpful regarding this topic.
Any sample code would be very helpful.
Firefox doesn't support writing files via File API yet and even when this will be added it will probably be accessible to web pages only and not extensions. In other words: yes, if you absolutely need to write to files then you should use low-level APIs. You want to store your data in the user profile directory (there is no extension directory, your extension is usually installed as a single packed file). Something like this should work to write a file:
var file = require("sdk/io/file");
var profilePath = require("sdk/system").pathFor("ProfD");
var filePath = file.join(profilePath, "foo.txt");
var writer = file.open(filePath, "w");
writer.writeAsync("foo!", function(error)
{
if (error)
console.log("Error: " + error);
else
console.log("Success!");
});
For reference: sdk/io/file, sdk/system
You could use TextReader.read() or file.read() to read the file. Unfortunately, Add-on SDK doesn't seem to support asynchronous file reading so the read will block the Firefox UI. The only alternative would be importing NetUtil and FileUtils via chrome authority, something like this:
var {components, Cu} = require("chrome");
var {NetUtil} = Cu.import("resource://gre/modules/NetUtil.jsm", null);
var {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm", null);
NetUtil.asyncFetch(new FileUtils.File(filePath), function(stream, result)
{
if (components.isSuccessCode(result))
{
var data = NetUtil.readInputStreamToString(stream, stream.available());
console.log("Success: " + data);
}
else
console.log("Error: " + result);
});