A way to prevent 3rd-party elements to be loaded on Safari? - macos

Basically, I'm looking for RequestPolicy for Safari. GlimmerBlocker, Privoxy and BFilter etc, those work well but none of them support "block 3rd party elements" feature.
I use GlimmerBlocker, and to imitate (barely) the function, I mainly put this code to filter script flooded website.
replace(/<(script|noscript|iframe)([\s\S]*?)<\/(script|noscript|iframe)>/img, "")
However I'm tired of repeating creating filters for each websites. Vice-versa, whitelisting will be the same.
If anybody had an idea to solve this, that would be so great. Thanks.

I made this proof-of-concept Safari extension to block external resources (images, objects, and scripts, but NOT link elements, such as stylesheet links) until allowed. It has a bare minimum number of features, but if you are interested, I might develop it further.
I say "external" and not "third-party" because I don't know to tell reliably if a resource is third-party or not. This extension just blocks all resources that come from a different host than the web page. As a result, it blocks too many resources by default.
You can right-click a blocked image and use a context menu command to whitelist the image host. If the blocked image didn't have a specified width and height, it will be invisible, so you won't be able to right-click it. (To remedy this, I will need to add code to make the empty image visible as a box.)
The whitelist command does not show up for blocked plugin objects (such as Flash objects) or scripts. I will have to add code to deal with that.
You can also whitelist the current site itself, meaning that all external resources will be allowed on that site. Again, this is done with a context menu command.
As yet, there is no way to remove items from either whitelist. This can be added.
Download the extension from here.
You can extract the source files from the extension package using this command:
xar -xf PartyPooper.safariextz
You are welcome to do whatever you like with the source.

Related

Uploading and referencing custom images in BigCommerce/Stencil

Recently started work on a BigCommerce project and on the homepage I want to have a theme area where normal site admin users can upload their own images based on holidays (Xmas, halloween etc) in the theme editor.
I know how to add in some custom elements in the theme editor using the Schema and Config files (headings, text, font colours etc), and how to reference them in the homepage. I'm also fine with referencing set images in the assets folder which aren't going to change, and manually coding references to them.
However I can't quite seem to work out how to add a custom image upload to the theme editor, or how to reference it in a page. Can't seem to find any answers in the Stencil documentation or usual Google searches etc either.
The Stencil Theme Editor currently only supports the file upload data type in the Optimized One-Page Checkout customization settings, but there are a couple of possible workarounds to allow the user to upload their custom background image and then reference it in Theme Editor settings:
One option would be to have the user upload their image to WebDAV, making sure that their image followed a naming convention that you specified. For example, the Halloween image could be required to have the file name halloween.png. You could map that value to a Theme Editor dropdown setting for Holiday Background>Halloween.
Another solution might be to have the user upload their image to WebDAV as mentioned above, but instead of a dropdown menu, you could have the user type their file's name into a text input setting in the Theme Editor. Keep in mind though that there's a 64 character limit for input values.
Hope this helps!
There are 4 ways to get images into the BigCommerce store.
You can:
Upload into the content folder through webdav. Then the images would be referenced like url.com/content/image.jpg. This does require a webdav connection and while everything does point you to using file managers like cyberduck, you can actually map a drive to a network resource to make this super easy. This mean you can create a z drive that is actually your bigcommerce content upload through webdav. It's pretty easy to set up and for customers to use. The drawback is that these files do not get put on a CDN so there's a little loss of performance.
Upload into the theme's images folders. This is complex and would require your client to figure out the stencil local dev connection and push versions up to their store. This would allow the images to be CDN'd but is super complex and your clients won't figure it out... It could also expose you to some long-term version control issues as they may be overwriting you or vice versa.
You can use the media manager to upload images. If you're referring to them in code, an easy trick is when your clients want to replace an image, to delete it and upload a new one with the exact same name... then the reference doesn't break. This is the easiest way to deal with site-wide issues from the client-side. Images are CDN'd this way as well.
You can consider using the marketing banner function for semi-temporary marketing messages. This is what it is made for, the images will be CDN'd and it's full GUI with no techy connections for your clients to figure out. This is perfect for banners that span a single page, but I don't think there is currently a side-wide setting for locations.

Plugins to set Bookmarks with Inherit Zoom in Acrobat (Mac)?

At work, we are required to set "Inherit Zoom" on all bookmarks and links within PDF files (using Adobe Acrobat). I have been surprised at how difficult it is to set this across multiple bookmarks. I.e., the only native way I have found to do this is by manually right-clicking on each link and editing the properties to Inherit Zoom.
This is a problem for a number of reasons. For one, when you set Inherit Zoom on a bookmark, you can no longer direct that bookmark or link to a specific destination within a page (aka an anchor). You must set the bookmark or link to bring you to a page number instead.
I could deal with that and work around it, if there was some way to set Inherit Zoom as the default for a document. Unfortunately, it appears that Acrobat requires you to manually edit every single link and/or bookmark. As you can imagine, this is a huge undertaking when working with large PDFs with many bookmarks and internal links.
I have been reading through forums (Adobe, here, elsewhere) and help pages for hours trying to find an answer and it seems the only successful ones are installing a plug-in that can change these settings throughout a document in one fell swoop. I'm hesitant to install 3rd party plug-ins for both security reasons, and the fact that they are often expensive. We're certainly willing to pay for a plug-in that takes care of this issue, but if there's a better way to do it then I would like to explore other options. There's also the worry that after we buy a 3rd party plug-in, there's no guarantee how long it will be supported by the devs or compatible with newest versions of Acrobat.
This has (apparently) been a common problem and request by Acrobat users for over 5 years. Someone out there has to have a good solution. Any advice or recommendations on a reliable plug-in would be much appreciated!
I have created an open-source (Java-based) app that allows you to apply
Actual size
Fit page
Fit visible
Fit width
Inherit zoom
to all bookmarks within a PDF document or entire directories of PDFs (enclosing subdirectories included) without selecting each item manually:
https://github.com/beatngu13/pdf-zoom-wizard/
In case anyone with the same problem finds this, I was able to work around the issue by creating documents in a LaTex editor first, then converting to a PDF. The anchors created in the Latex editor had the Inherit Zoom functionality, if not the explicit settings in properties.
I also used the software Debenu Aerialist, which would have worked for editing links or bookmarks en masse. It's not a perfect solution or product but it worked.

Content Script Injection at Install for Firefox Web Extension

If content scripts are specified in manifest.json for Firefox, Firefox will also load content scripts for already opened tabs and execute them even the tabs are already in loaded and ready state.
Google Chrome does not add any content script when extension is installed for already opened tabs. The content script is loaded when the page is refreshed for the older tabs.
I want to ask is Firefox's behavior is expected or bug?
As far as compatibility goes, it's a bug.
Chrome does not do that.
As a result, many extensions implement custom logic to achieve the effect.
One has to take into account side effects. Suppose your content script injects some UI into the page. Then the extension is updated. That amounts to extension restart, and suddenly you have 2 copies of the UI. Also valid if you just attach event listeners, as (at least in case of Chrome) the old content script's context continues to exist (in an "orphaned" state).
The last point is very important and probably the reason why Chrome doesn't do it by default. At some point I made a very long post about this problem - if you're going to report this as a bug to Mozilla, please include that. There's also this feature request that is related.
What would be sensible (and backwards compatible) is to add a parameter to content script description in the manifest - whether to inject into existing pages. It will be up to developers to guarantee that side effects are taken care of. This usually requires even more code to just communicate to the old script that it needs to wind down and clean up.

In a web app, how do I preload a set of arbitrary files to view them more quickly as I go through them?

Suppose I have a .NET web application that contains two panes. One pane is a viewer capable of displaying a variety of large file types. The other pane contains an arbitrary list of files, e.g. file1.docx, file2.xlsx, file3.pptx, file4.txt, file5.doc, file6.htm, file7.zxz, file8.exe etc.
The user is capable of selecting any file in the list and displaying it in the adjacent pane when the selection changes, presumably via client-side Javascript. Given the user has selected some file, e.g. file1.docx, is there a way to prefetch/preload some number of files in the list, e.g. file2.xlsx and file3.pptx while the user is viewing file1.docx?
If this could be done in the background with an asynchronous Ajax-like call, it would make the application appear faster for users who went from file to file in sequence. I am assuming that the prefetch call could be smart enough not to attempt to request files that could not be viewed, e.g. exe files.
Any help or examples would be much appreciated.
Use hidden iframes to load subsequent documents after the first click. Use a plugin detection script to check file extension support prior to allowing the click event. If you want to prerender, then use each browsers prefetch API:
Chromium Prerender API
MDN: Link Prefetching FAQ
MSDN: Prefetch and Prerender Support
MDN: Link Types

How to customize the windows shell to display files from a remote source and allow custom drawing?

Is it possible, (via some shell extension or similar) to customize the Windows shell (explorer.exe) to accomplish the following?
Make it, upon navigating to a predefined path:
draw over its surface - custom background, or even add custom forms for data input
display custom listview items based on the "virtual" path provided (something analogous to what explorer is doing when browsing a FTP repository - the items shown are not contents of a local folder, but rather some "virtual" items physically located on the FTP server)
The idea is to reuse the visage and navigation elements of Explorer without re-implementing the whole functionality and make it look native on all Windows versions for a remote file browser (file lists+files alone served by a custom web service).
I think you need to implement a Explorer Namespace Extension. There is some good information floating around on codeproject etc that you will probably need since the official documentation is not the best.

Resources