This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,15 @@ | ||
# Facebook-Story | ||
A really simple extension for extracting Facebook Story CDN links | ||
|
||
## How It Works | ||
1. **Check for Element:** The script checks for a specific `<div>` element on a the `facebook.com/stories` url for extracting the CDN. | ||
2. **Find Video URL:** It scans the entire HTML content of the page to find all `data-video-url` values and get the last one (Which seems to be in higher quality (to me)) | ||
3. **Retry:** If the element is not found, it waits for 2 seconds and checks again. | ||
|
||
## Usage | ||
1. Add this script to your browser's console or include it in a web page. | ||
2. Open the console to see the logs. | ||
3. Watch for messages about the element and the last video URL. | ||
|
||
## Note/Concerns | ||
The script doesn't always seem to be actively running whenever the story is opened. It only seems to run whenever the story page (`facebook.com/stories`) is directly opened or refreshed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { | ||
if (tab.url && tab.url.startsWith("https://www.facebook.com/stories/")) { | ||
chrome.scripting.executeScript({ | ||
target: { tabId: tabId }, | ||
files: ['content.js'] | ||
}); | ||
} | ||
}); | ||
|
||
chrome.action.onClicked.addListener((tab) => { | ||
chrome.tabs.create({ url: "https://github.com/SatoX69/Facebook-Story" }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
function CDN_Elem() { | ||
const element = document.querySelector('div[data-force-autoplay="false"][data-use-device-sound-state="true"]'); | ||
|
||
if (element) { | ||
var htmlContent = document.documentElement.innerHTML; | ||
var regex = /data-video-url="(.*?)"/g; | ||
var lastVideoUrl; | ||
var match; | ||
|
||
while ((match = regex.exec(htmlContent)) !== null) { | ||
lastVideoUrl = match[1]; | ||
} | ||
|
||
if (lastVideoUrl) { | ||
lastVideoUrl = CDN_link(lastVideoUrl); | ||
if (confirm(`Open Story`)) { | ||
window.open(lastVideoUrl, '_blank'); | ||
} | ||
} else { | ||
console.log("No CDN Found"); | ||
} | ||
} else { | ||
console.log("CDN not found, retrying..."); | ||
setTimeout(CDN_Elem, 2000); | ||
} | ||
} | ||
|
||
CDN_Elem(); | ||
|
||
function CDN_link(str) { | ||
return str.replace(/&/g, "&"); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"manifest_version": 3, | ||
"name": "FB Story CDN", | ||
"version": "1.0", | ||
"description": "Extracts the FB Story element for sharing or downloading directly. (Refresh on the story page to activate it)", | ||
"permissions": ["activeTab", "scripting"], | ||
"background": { | ||
"service_worker": "background.js" | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": ["https://www.facebook.com/stories/*"], | ||
"js": ["content.js"] | ||
} | ||
], | ||
"icons": { | ||
"16": "icons/icon16.png", | ||
"48": "icons/icon48.png", | ||
"128": "icons/icon128.png" | ||
}, | ||
"action": { | ||
"default_icon": { | ||
"16": "icons/icon16.png", | ||
"48": "icons/icon48.png", | ||
"128": "icons/icon128.png" | ||
} | ||
} | ||
} |