Skip to content

Commit

Permalink
fix video downloads again
Browse files Browse the repository at this point in the history
  • Loading branch information
flurrux committed Jun 10, 2023
1 parent e9755b9 commit 4ea49e9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ so before you use this extension, you have to be willing to wait for a fix when

## previous breakage

on March 30th 2023, i've noticed that video downloads on carousel posts were broken again.
this was due to Instagram now making a specific API call several times when i've assumed it would only be made once.
the fix is available in the newest release (1.3.16).

please note that there may be another error with video downloads from single-post pages. if a download fails for you, try to reload the page and download again. i'll keep an eye out for this problem.

on June 10th 2023, i've noticed that video downloads from posts were broken again. my previous fix was not as robust as i had hoped, but the latest fix should remedy this.


## current limitations are:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ webRequest.onSendHeaders.addListener(

// # graphql #

const polarisPostRootQuery = "PolarisPostRootQuery";

const graphqlUrls: string[] = [
// "*://www.instagram.com/graphql/query",
"*://www.instagram.com/api/graphql"
Expand All @@ -56,6 +58,13 @@ webRequest.onSendHeaders.addListener(
const { requestHeaders } = details;
if (!requestHeaders) return;
console.log("graphql request headers", details);

const X_FB_Friendly_Name_entry = requestHeaders.find(
({ name }) => name === "X-FB-Friendly-Name"
);
if (!X_FB_Friendly_Name_entry) return;
if (X_FB_Friendly_Name_entry.value !== polarisPostRootQuery) return;

tabs.sendMessage(
details.tabId,
{ requestHeaders: objectifyRequestHeaders(requestHeaders) }
Expand All @@ -68,9 +77,16 @@ webRequest.onSendHeaders.addListener(
webRequest.onBeforeRequest.addListener(
(details) => {
console.log("graphql request body", details);

const formData = details.requestBody?.formData;
if (!formData) return;

const { fb_api_req_friendly_name } = formData;
if (!fb_api_req_friendly_name) return;
if (fb_api_req_friendly_name[0] !== polarisPostRootQuery) return;

tabs.sendMessage(
details.tabId,
{ requestBody: details.requestBody?.formData }
details.tabId, { requestBody: formData }
);
},
{ urls: graphqlUrls },
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "insta-loader",
"description": "download buttons for instagram media.",
"version": "1.3.16",
"version": "1.3.17",
"icons": {
"16": "assets/icons/insta-loader-icon-16.png",
"48": "assets/icons/insta-loader-icon-48.png",
Expand Down
2 changes: 1 addition & 1 deletion dist/service-worker-loader.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import './assets/background.ts.069ea2dd.js';
import './assets/background.ts.850526c9.js';
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"name": "insta-loader",
"description": "download buttons for instagram media.",
"version": "1.3.16",
"version": "1.3.17",

"icons": {
"16": "assets/icons/insta-loader-icon-16.png",
Expand Down

0 comments on commit 4ea49e9

Please sign in to comment.