Skip to content

Latest commit

 

History

History
9 lines (8 loc) · 1.69 KB

fb_getallalbumidfromcurrentwebsite-js.md

File metadata and controls

9 lines (8 loc) · 1.69 KB
title date categories
Fb_getAllAlbumIdFromCurrentWebsite.Js
2023-11-23
useful-script-en

how to add bookmarklet in chrome
export default { name: { en: "Get all fb Album ID from current page", vi: "Get all fb album id from current page", }, description: { en: "Get all album id in facebook website", en: "Get all album id in facebook page", }, whiteList: ["https://www.facebook.com/*"], onClick: function() { // Get all album ids present in the website – While viewing 1 album list by user/group /page const list_a = document.querySelectorAll("a"); let list_id = []; for (let a of [location, ... Array.from(list_a)]) { const page_album_id = /(?<=\/photos\/a\.) (.\d+?) (?=\/)/.exec(a.href); if (page_album_id &&&; page_album_id[0]) { list_id.push(page_album_id[0]); } const group_album_id = /(?<=set\=oa\.) (.\d+?) ($|(?=&)) /.exec(a.href); if (group_album_id &&&; group_album_id[0]) { list_id.push(group_album_id[0]); } const user_album_id = /(?<=set\=a\.) (.\d+?) ($|(?=&)) /.exec(a.href); if (user_album_id &&&; user_album_id[0]) { list_id.push(user_album_id[0]); } } filter duplicate: https://stackoverflow.com/a/14438954 list_id = [... new Set(list_id)]; if (list_id.length) prompt( 'Found ${list_id.length} album id in website and on url.', list_id.join(", ") ); else prompt( "No ALBUM ID found in website!\nAre you on the correct album page?\nWebsite Example:", "https://www.facebook.com/media/set/?vanity=ColourfulSpace&set=a.945632905514659" ); }, };