Getting Twitter data in a web extension without remote scripts - twitter

I am developing a WebExtension for Firefox. In order to post my extension, it must not have any remote scripts in it.
In order to display some tweets in my extension's menu, I have used the Twitter-Post-Fetcher library, but I can't post my extension with it because the library uses remote scripts from twitter.com.
I prefer not to use the Twitter API if possible, because the requests would come from the extension's users.

No remote scripts means that if you are going execute code in the context of your extension, then the code must be included in the extension package, not hosted on some server. While there may be other ways to accomplish this (e.g. running the code in the page context, which may be acceptable, but may not), the default way to accomplish this is to: download the code that you are executing and use a copy that you include in the extension package.
This is the case for all code, including libraries such as jQuery. It is highly recommended that the code be an exact byte-by-byte copy of code that can be downloaded from a public repository, and that you indicate within your extension package the exact URL you used to obtain the code.
The reason for this is security. If downloading code at runtime was permitted, then that code could be trivially changed at any time. It would mean that having the add-on reviewed by Mozilla would be of no benefit.
Please see the Review Policies page on MDN, and all the pages linked from there, for more details.

Related

Generate a .zip file using Forge Design Automation

I'm working on a web site using Forge Design Automation for AutoCAD, and I'd like to have a .zip file returned. Does the .zip file have to go back to a URL (folder) located in site, or can it be downloaded directly to my view (MVC) through the controller? And, if it can come back to the view, how do provide arguments to my workitem?
Thank you.
The Design Automation will want to PUT/POST the resulting zip file somewhere. So you must supply a resource (URL) that can be operated on by one of those verbs.
Your website then can offer up the same resource to download to your clients. Clients cannot download directly from Design Automation as there's no HTTP resource that they could GET.
We can take advantage of the Forge OSS signed resource with read/write permission, so that Design Automation API will put the file to the Forge OSS bucket, and we can use the sample link to download the file. Please check my sample here. Although it's a Revit sample, the signed resource part can be applied to Design Automation API for AutoCAD, too.
https://github.com/yiskang/forge-revit-fbx-export-bim360/blob/master/routes/da4revit.js#L92
https://github.com/yiskang/forge-revit-fbx-export-bim360/blob/master/routes/da4revit.js#L216
https://github.com/yiskang/forge-revit-fbx-export-bim360/blob/master/public/js/ForgeDesignAutomation.js#L58
https://github.com/yiskang/forge-revit-fbx-export-bim360/blob/master/public/js/ForgeDesignAutomation.js#L220

FTP with Swift 4/5 (with/without extra framework)

First of all: I know about the security concerns regarding ftp, so please no discussion about this here - ftp has to be used.
My app has to log into a server with ftp (with username/password), search for and download a file, delete it from the server, then upload an edited version.
I've been searching for tutorials on how to even get a connection to a server via ftp but all I found were Apple's documentation from 2012 here and their documentation about the different functions here (and a bunch of weird "Swift FTP" biking videos on youtube...). Every other example I found (usually <2015) uses some additional framework or library but there don't seem to be any proper tutorial for Swift 5 or even Swift 4.
Is it even still possible to use FTP with Swift 5 (is it still supported?) and if so, how? Or is there simply no point trying to get any of Apple's stuff to work and better to just use an extra framework like FileProvider?
At first I was using FileProvider, unfortunately the library is pretty buggy currently, with functions being called twice (which you can kind of prevent by using a "firstTimeCalled" bool check) and if the server's slow(-ish), you also might not get e.g. the full list of files in a directory because FileProvider stops receiving answers before the server's actually done.
I haven't found any other FTP libraries for Swift that work (and are still supported), so now I'm using BlueSocket (which is able to open sockets, send commands to the server and receive commands from it) and built my own small library that can send/receive,... files (using the FTP codes) around it.

NativeScript - How to create a webview with request blocking/redirection?

I'm trying to create a webview with the capability to block/redirect certain urls requested inside the webview (not just the page url, but also the requests sent from the page, think of it as what a browser extension is able to do).
After some research, the closest I get was this Swift/Obj-c approach of use NSUrlProtocol: https://www.raywenderlich.com/2292-using-nsurlprotocol-with-swift, and the doc of the native-webview-ext mentioned something about WKURLSchemeHandler https://github.com/Notalib/nativescript-webview-ext .
I'm new to mobile development and this feature is crucial for my project. I wonder if anyone has experience building this out in NativeScript, I hope I don't have to convince my team and my boss to write this in Swift instead :(.
As you see in the webview-ext plugin docs, it does support overriding resource urls. Refer the registerLocalResource method.
Just in case, even if that is not supported you don't have to write your whole project in Swift as you can always access all native apis from JavaScript / TypeScript itself, read more about it here.

Purpose of some of the JavaScript files in an ASP.NET MVC project under the Scripts folder

I always see these few files under the Scripts directory:
ai.0.22.9-buildXXXXX.js
ai.0.22.9-buildXXXXX.min.js
jquery-[version #].min.map
According to this answer, I can wipe out the Scripts folder. But I usually leave these 3 files alone, because I am afraid of bad consequences.
So What are the purposes of each file?
Microsoft Application Insights JavaScript SDK
Application Insights tells you about your app's performance and usage.
By adding a few lines of code to your web pages, you get data about
how many users you have, which pages are most popular, how fast pages
load, whether they throw exceptions, and more. And you can add code to
track more detailed user activity. ai.0.22.9-buildXXXXX.min.js can be
removed if you dont need to view site statics
For more details on how to use it
jquery-[version #].min.map
It is used for Source Mapping
Consider when you start debugging and you are on the particular line.
And you press (F11 or Click Step into Next Function Call), the
debugger tool will take you to jquery.min.js. And looking at jquery
minified version, it is impossible to find out the error. But with
source maps, you can let the browser’s debugger "map" the lines in the
compressed file into the uncompressed source. For Source map to work
successfully, two things are required.
1. Value of sourceMappingURL exists on your server or locally.
2. Browser Support
For further details
if you don't need it you can remove it
ai.*.js files are for Application Insights. Not required and can be removed, unless if using Application Insights.
*.map are for debugging purposes of JavaScript files. I doubt it will be necessary to debug the jQuery plugin. Not required and can be removed.

Use Dynamic Javascript in iOS Share Extension

I am developing a share extension for iOS 8 and it seem like i can run javascript code on page to grab some information like markup of the mage
But on the apple document it says that javascript code must be inside a .js file but my javascript code is coming from server and it is dynamic.
Is it possible to run javascript i downloaded from server or can I change js file contents everytime I need to use it?
You can't do this using the built-in support in the current share extension system.
The Javascript file needs to be listed by name in the extension's Info.plist, in the value of the NSExtensionJavaScriptPreprocessingFile key. The file named there needs to exist in the app extension's bundle. But bundles are not writeable, so you can't replace or change the file.
You might be able to do something like you describe if you:
Include a basic JS file that just returns the entire page source to your extension.
Use JavaScriptCore.framework to further process that data in your extension.
I don't know of any reason why that wouldn't work, but I haven't tried it, and it's kind of unusual. Still, given your needs, it's worth investigating.

Resources