OnlyFans Save Media Bookmarklet 1.0.0

Code for Browser Bookmarklet used to quickly save post media (photo or video).

by AntowaKartowa

JavaScript

/* 
	This bookmarklet is kind of lazy - opens all media (images and video) in new tabs from 
	particular post. It checks whether zoom popup is opened. If so it takes media data from
	popup slides. (Didn't had opportunity to check it on popups that contain more then 3 
	media files).
	
	If zoom popup is closed it checks all post elements from posts list to be fully visible.
	Thus make sure that post is fully visible including post title. Possibly calculation 
	could be improved.
	
	It turns out that images in the post items tend to have some size limitations. I turns 
	out that frequently (not always, probably depends on size of uploaded images) opening 
	post images in zoom popup has much bigger size. So to get best resolution you have to
	open images in zoom mode. Probably it could be automated in future improvements.
*/


/* 
	Firefox require wrap code in IIFE, otherwise page from which you will call it becomes blank. 
	So if you want to continue watching other photos from that page it requires page reload. 
	Which is absolutely inconvenient. Have no idea why it happens, so it easier just to use IIFE.
*/

(function() {
	// Kind of minor optimization. Maybe it has no sens.
  window._popup ??= document.querySelector('.pswp__container');
  window._posts ??= document.querySelector('.g-page-content__body .vue-recycle-scroller__item-wrapper');

  getMedia(window._popup, window._posts).map(getSource).map(openMedia);

	// Current code can open duplicate found by picture and img tags. Could be improved in
	// the future. But at the moment I didn't saw picture tag in page markup.
  function getMedia(popup, postsContainer) {
    if (popup.getBoundingClientRect().height) {
      return [...popup.querySelectorAll('.pswp__zoom-wrap :is(img, picture, video)')];
    } else {
      let posts = [...postsContainer.querySelectorAll('.vue-recycle-scroller__item-view')];
      let postInFocus = posts.find(el => {
        let coords = el.getBoundingClientRect();

        return...