|
| 1 | +export default { |
| 2 | + icon: "https://www.facebook.com/favicon.ico", |
| 3 | + name: { |
| 4 | + en: "Facebook - Download video/reel/watch", |
| 5 | + vi: "Facebook - Tải video/reel/watch", |
| 6 | + }, |
| 7 | + description: { |
| 8 | + en: "Download facebook video/reel/watch", |
| 9 | + vi: "Tải facebook video/reel/watch", |
| 10 | + }, |
| 11 | + blackList: [], |
| 12 | + whiteList: ["https://www.facebook.com/*"], |
| 13 | + runInExtensionContext: false, |
| 14 | + |
| 15 | + func: function () { |
| 16 | + // Original source code: https://gist.github.com/monokaijs/270e29620c46cabec1caca8c3746729d |
| 17 | + |
| 18 | + let url = prompt("Nhập link video/reel/watch:", location.href); |
| 19 | + let videoId = url.match(/\/(?:videos|reel|watch)(?:\/?)(?:\?v=)?(\d+)/); |
| 20 | + if (!videoId || videoId.length < 2) { |
| 21 | + alert( |
| 22 | + "Link không đúng định dạng, không tìm thấy video/reel/watch id trong link." |
| 23 | + ); |
| 24 | + return; |
| 25 | + } |
| 26 | + let stringifyVariables = function (d, e) { |
| 27 | + let f = [], |
| 28 | + a; |
| 29 | + for (a in d) |
| 30 | + if (d.hasOwnProperty(a)) { |
| 31 | + let g = e ? e + "[" + a + "]" : a, |
| 32 | + b = d[a]; |
| 33 | + f.push( |
| 34 | + null !== b && "object" == typeof b |
| 35 | + ? stringifyVariables(b, g) |
| 36 | + : encodeURIComponent(g) + "=" + encodeURIComponent(b) |
| 37 | + ); |
| 38 | + } |
| 39 | + return f.join("&"); |
| 40 | + }, |
| 41 | + fetchGraphQl = function (doc_id, variables) { |
| 42 | + return fetch("https://www.facebook.com/api/graphql/", { |
| 43 | + method: "POST", |
| 44 | + headers: { "content-type": "application/x-www-form-urlencoded" }, |
| 45 | + body: stringifyVariables({ |
| 46 | + doc_id: doc_id, |
| 47 | + variables: JSON.stringify(variables), |
| 48 | + fb_dtsg: require("DTSGInitialData").token, |
| 49 | + server_timestamps: !0, |
| 50 | + }), |
| 51 | + }); |
| 52 | + }; |
| 53 | + |
| 54 | + fetchGraphQl("5279476072161634", { |
| 55 | + UFI2CommentsProvider_commentsKey: "CometTahoeSidePaneQuery", |
| 56 | + caller: "CHANNEL_VIEW_FROM_PAGE_TIMELINE", |
| 57 | + displayCommentsContextEnableComment: null, |
| 58 | + displayCommentsContextIsAdPreview: null, |
| 59 | + displayCommentsContextIsAggregatedShare: null, |
| 60 | + displayCommentsContextIsStorySet: null, |
| 61 | + displayCommentsFeedbackContext: null, |
| 62 | + feedbackSource: 41, |
| 63 | + feedLocation: "TAHOE", |
| 64 | + focusCommentID: null, |
| 65 | + privacySelectorRenderLocation: "COMET_STREAM", |
| 66 | + renderLocation: "video_channel", |
| 67 | + scale: 1, |
| 68 | + streamChainingSection: !1, |
| 69 | + useDefaultActor: !1, |
| 70 | + videoChainingContext: null, |
| 71 | + videoID: videoId[1], |
| 72 | + }) |
| 73 | + .then((res) => res.text()) |
| 74 | + .then((text) => { |
| 75 | + try { |
| 76 | + let a = JSON.parse(text.split("\n")[0]), |
| 77 | + link = |
| 78 | + a.data.video.playable_url_quality_hd || a.data.video.playable_url; |
| 79 | + |
| 80 | + if (link) { |
| 81 | + window.open(link); |
| 82 | + } |
| 83 | + } catch (e) { |
| 84 | + alert("Lỗi: " + e); |
| 85 | + } |
| 86 | + }) |
| 87 | + .catch((e) => { |
| 88 | + alert("Lỗi: " + e); |
| 89 | + }); |
| 90 | + }, |
| 91 | +}; |
0 commit comments