Is it feasible to embed Instagram in an iframe without using the API?

Is there an alternative method to embed Instagram using iframe without the need for an API?

Answer №1

To determine if a specific URL (example.com) is permitted within an iframe for a particular Origin, you can use the following method:

function checkIFramePermission({ header, origin }) {
  if (header["X-Frame-Options".toLowerCase()]) {
    let options = header["X-Frame-Options".toLowerCase()].toLowerCase();
    if (options === "SAMEORIGIN".toLowerCase() || options === "DENY".toLowerCase()) {
      return false;
    } else if (~options.indexOf("ALLOW-FROM".toLowerCase())) {
      let allowedOrigins = options.split(" ").slice(1);
      return allowedOrigins.find(
        _o => url.parse(_o).host === url.parse(origin).host
      );
    }
  }
  if (header["Content-Security-Policy".toLowerCase()]) {
    let _options = header["Content-Security-Policy".toLowerCase()];
    let findOriginInSource = source_name => {
      _options = _options.split(";");
      _options = _options.find(_o => _o.indexOf(source_name) > -1);
      _options = _options.split(" ").slice(1);
      return _options.find(_o => url.parse(_o).host === url.parse(origin).host);
    };
    if (_options.indexOf("frame-src") > -1) {
      return findOriginInSource("frame-src");
    } else if (_options.indexOf("child-src")) {
      return findOriginInSource("child-src");
    } else if (_options.indexOf("default-src")) {
      return findOriginInSource("default-src");
    } else {
      return true;
    }
  } else {
    return true;
  }
}
const got = require("got");
const metascraper = require("metascraper")([
  require("metascraper-author")(),
  require("metascraper-date")(),
  require("metascraper-description")(),
  require("metascraper-image")(),
  require("metascraper-logo")(),
  require("metascraper-clearbit-logo")(),
  require("metascraper-publisher")(),
  require("metascraper-title")(),
  require("metascraper-url")()
]);
const Domain = "example.com";
(async () => {
     const { body: html, url, headers } = await got(Domain);
     const metadata = await metascraper({ html, url });
     const isAllowed = checkIFramePermission({
                        header: headers,
                        origin: "www.app4pc.com"
                    })
})();

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to dynamically append options to a Bootstrap selectpicker?

I'm attempting to design a dropdown feature that, when activated by clicking on the first list item, displays a new list of related items next to the initial selection. Here's an illustration: https://i.sstatic.net/fMxAj.png My approach involve ...

Dividing internal CRUD/admin panel from the live application

Currently developing a moderately complex react app with redux. We have a production version that meets our requirements and now we are working on an administrative area for a local version of the application. This local version will only have basic CRUD f ...

Navigating through tabs in a Meteor application: How to maintain the active tab when using the back button

I am working on a multi-page meteor application where each page includes a navigation template. To switch between pages, I am using iron-router. The user's current page is indicated by setting the appropriate navigation link's class to 'ac ...

Navigating Overlays with Python and Selenium

driver.find_element_by_class_name("lnkClassInfo").click() time.sleep(2) element = driver.find_element_by_css_selector("#popup input[value='BOOK THIS CLASS NOW']") driver.execute_script("arguments[0].click();", element) ERROR: selenium.common.exc ...

Adding wrapAll in jQuery or PHP after tags with identical IDs can be achieved by selecting all the target elements

web development <?php foreach ($forlop as $value) : ?> <?php $stringTitle = substr($value->getTitle(), 0, 1); ?> <?php if(is_numeric($stringTitle)){ echo "<h3 id ...

Utilizing Twitter API authentication to prevent hitting rate limits

Currently, I am implementing the Twitter API to showcase the most recent tweets from 4 distinct users on my webpage. It seems that once a certain number of calls are made, an error message appears stating "NetworkError: 400 Bad Request" and prevents the tw ...

Access the array values by their respective keys in an object that is returned from a custom JavaScript file utilizing the Node.js file system

I recently came across a config file with a unique format, as shown below: define([], function () { return { productItems: { item1: ['Apple', 'Ball', 'Car'], item2: [&apo ...

Is the navbar-nav being unexpectedly placed below the navbar-brand?

As my screen width decreases to 767px, the navigation collapses as expected. However, at 768px, the navbar-nav drops below the navbar-brand until reaching 795px where they realign again. These values may vary based on the size of your navigation. Check o ...

NestJS Logger: Issue setting logger types in main.ts

When attempting to specify logger types in main.ts as illustrated in the official documentation: const app = await NestFactory.create(ApplicationModule, { logger: ['error', 'warn'], }); await app.listen(3000); I am encountering an i ...

Display website content with a Bootstrap modal popup

When using the bootstrap modal popup, it's important to ensure that the content displayed does not already exist on the page. The issue of images from the page appearing on the popup is demonstrated in the image linked below. Can someone provide guida ...

React Nested Menu Selection

Having trouble displaying TextField values in my React app. Utilizing material UI and material-ui-phone-number packages. Noticed that values appear behind when clicking the flag due to zIndex issue. Looking for modifications only on dialog2.js For code ex ...

How come the button doesn't get enabled after three seconds even though ng-disabled is being used?

index.html <html ng-app='myApp'> <head> <title>TODO supply a title</title> <script src="js/angular.js" type="text/javascript"></script> <script src="js/using built-in directives. ...

What could be causing Wordpress Jquery to only function properly after a page refresh?

Here is the code snippet I am working with: <script type="text/javascript"> jQuery( document ).ready(function() { jQuery('#bookbtn_loc_1').on('click', function(event){ jQuery("a.da-close").click(); ...

Link to xpath concept

I am trying to create a hyperlink to a particular spot on a website that I do not have access to edit. Unfortunately, there is no identifiable ID near the location I want to link to, so using <a href="http://example.com/page.html#location"> will no ...

Guide to implementing Google Adsense on a page post-load using Angular 6

Hi there, I recently completed my website www.revlproject.org and now I'm trying to get approved for Google Adsense. However, I keep receiving the message "valuable inventory: no content." After some investigation, I realized that because my site is b ...

How can I make CSS images appear beside specific links?

Currently, I have implemented the following CSS: .entry a { padding: 2px 0 0 8px; background: transparent url(images/link_arrow_light.gif) left top no-repeat; text-decoration: underline; } It is functioning correctly, but the image is being added t ...

Unusual margin glitch discovered in Chrome version 9

Encountered a strange issue with Google Chrome 9: A left-margin for an input element is specified but Chrome fails to apply it upon page load. Oddly enough, when I toggle the specific declaration off and then back on using Developer Tools, the margin is f ...

What can be done to resolve the error message "This language feature is only supported for ECMASCRIPT6 mode" in Google Tag Manager?

I attempted to implement some JavaScript code in GTM, but encountered an error. The error occurs at this line window.sbHooks.addAction('sbCoreState::CreateBets/success', (data, response) => { where I utilized a custom Vue.js hook. How can I ...

Module 'js' not found

Upon adding a request, I encountered this error message. I attempted npm install js and added var js = require("js") in my app.js file, but unfortunately it did not resolve the issue. My express server is running on localhost. Error: Cannot find module &a ...

Implementing OAuth2 in a Microservices architecture to establish a user account

In my current setup, I am utilizing a React Application along with a separate Express API. My goal is to allow users to register through my React app. To do this, I believe the oauth2 flows should follow these steps: Prompt the user for information (suc ...