ozntel / oz-image-in-editor-obsidian

This Obsidian plugin to view Images, Transclusions, iFrames and PDF Files within the Editor without a necessity to switch to Preview.
336 stars 13 forks source link

Feasibility of specifying a custom User Agent for iframe embeds #112

Open SimplGy opened 1 year ago

SimplGy commented 1 year ago

Might be nice to be able to set the UA for iframe embeds. My use case would be to set it to a mobile UA so that websites render in a more small-size friendly, content-forward way. It could also be useful for setting a robot/crawler UA to skip modals and other JS interrupts on some websites.

I see there's an abstraction for doing the CustomHtmlDecoration, wasn't sure how well that would play with throwing some script into the frame every time.

Do you think this FR is this generally interesting for your plugin or a little too niche?

SimplGy commented 1 year ago

Example, before:

image

Mockup, after (changed UA):

image

SimplGy commented 1 year ago

Noting that when I was playing around with this, I got a lot of "Blocked a frame with origin "app://obsidian.md" from accessing a cross-origin frame" -- reaching in and swapping the UA from the outside might not be feasible. iframes support specifying a CSP but I'm not sure if that's enough to support this.