Facebook custom background

Custom facebook background

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да инсталирате разширение, като например Tampermonkey .

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като Tampermonkey.

За да инсталирате този скрипт, трябва да имате инсталиран скриптов мениджър.

(Вече имам скриптов мениджър, искам да го инсталирам!)

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

(Вече имам инсталиран мениджър на стиловете, искам да го инсталирам!)

// ==UserScript==
// @name         Facebook custom background
// @namespace    http://tampermonkey.net/
// @version      0.0.5
// @description  Custom facebook background
// @author       DauMoe
// @match        https://www.facebook.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=facebook.com
// @grant        none
// ==/UserScript==
(()=>{"use strict";function e(){return new Promise((function(e,t){var n=indexedDB.open("ImageStorageDB",1);n.onerror=function(e){t("Error opening IndexedDB")},n.onsuccess=function(t){e(t.target.result)},n.onupgradeneeded=function(e){e.target.result.createObjectStore("images",{keyPath:"id"}).createIndex("base64","base64",{unique:!1})}}))}var t="__fb-dark-mode",n="__fb-light-mode",o="transparent",r="darken",a="#2f2f2fa6",c="#25272880",s="#2527289e",i=o,d="lighten",u="#d7d4d469",l="#ffffff99",g="#ffffff42",f=o;!function(){var m=document.createElement("div"),p=document.createElement("div"),y=document.createElement("input"),A=function(e){m.style.opacity=0,setTimeout((function(){m.style.backgroundImage="url(".concat(e,")"),m.style.opacity=1}),0)};y.type="file",y.accept="image/png, image/jpeg, image/jpg",y.style.display="none";var b={width:"50px",height:"50px","border-radius":"25px",position:"fixed",left:"16px",bottom:"16px","z-index":3,"background-image":"url(".concat("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAEPSURBVHgB7ZjtDYIwEIYPJmAEHIENGMFR2AQ2gg10A9gANjjvQjW1Ba5WtP3RJ7nYpG/aJ+b4KAAEIpZUPdWMYejZgV0yNbhRFRCWhapioZ4GNcTBwEII8bBYQhkBf8TcP4fISEISSUgiCUkkIYkkJJGEJH4iRA/wguoKPpjvknACtEynlmsdsu/7fyJE0/Xz3fcg0xhLNkLeTwjXg8CsqhQyOrt5byFce2LUYjwuhAwe5b8V6jY2aR0yu3lvIbR7QqdxyFh5byHc7gkdnqvR/YBp9ZMZODx10NRIPyWcy0RbXHQhfTK6O3U6l0kkIQnuoRnCf4p5wf/QHeJhiO6DVU5X+cQDqgHCsKi9K3Z5AJ4wAkK8W5ViAAAAAElFTkSuQmCC",")"),"background-color":"#33afd1","background-blend-mode":"normal","background-position":"center","background-repeat":"no-repeat","background-size":"26px",cursor:"pointer"};Object.assign(m.style,{width:"100vw",height:"100vh",position:"fixed",top:0,left:0,"background-size":"cover","background-repeat":"no-repeat","background-position":"center","z-index":-1,transition:"background-image 0.5s ease-in-out, opacity 0.5s ease-in-out",opacity:0}),Object.assign(p.style,b),document.body.appendChild(m),document.body.appendChild(p),document.body.appendChild(y),y.addEventListener("change",(function(t){var n=t.target.files[0];n&&function(e,t){var n=new FileReader;n.onloadend=function(){t(n.result)},n.readAsDataURL(e)}(n,(function(t){A(t),function(t){e().then((function(e){var n=e.transaction("images","readwrite"),o=n.objectStore("images"),r={id:"backgroundImage",base64:t};o.put(r),n.oncomplete=function(){console.log("Image saved to IndexedDB")},n.onerror=function(){console.error("Error saving image to IndexedDB")}})).catch((function(e){return console.error(e)}))}(t)}))})),p.addEventListener("click",(function(){y.click()})),new Promise((function(t,n){e().then((function(e){var o=e.transaction("images","readonly").objectStore("images").get("backgroundImage");o.onsuccess=function(e){e.target.result?t(e.target.result.base64):n("No image found")},o.onerror=function(){n("Error retrieving image from IndexedDB")}})).catch((function(e){return n(e)}))})).then((function(e){A(e)})).catch((function(e){console.error(e)}));var h=function(){var e=document.documentElement.classList.contains(t)||!document.documentElement.classList.contains(n)&&window.matchMedia("(prefers-color-scheme: dark)").matches,s=location.pathname.startsWith("/groups/");m.style.backgroundBlendMode=e?r:d,m.style.backgroundColor=e?a:u,document.documentElement.style.setProperty("--card-background",e?c:l),document.documentElement.style.setProperty("--surface-background",s?o:g)},k=new MutationObserver((function(e){var r=location.pathname.startsWith("/photo");e.forEach((function(e){if(e.target===document.documentElement&&"class"===e.attributeName)h();else if("childList"===e.type&&"DIV"===e.target.tagName){var a,d,u,m=null===(a=e.addedNodes)||void 0===a?void 0:a[0];if(m)null!==(d=m.classList)&&void 0!==d&&d.contains(t)?(m.style.setProperty("--always-black",i),m.style.setProperty("--surface-background",r?"#2527282b":s),m.style.setProperty("--web-wash",o),m.style.setProperty("--card-background",r?o:c)):null!==(u=m.classList)&&void 0!==u&&u.contains(n)&&(m.style.setProperty("--always-black",f),m.style.setProperty("--surface-background",r?o:g),m.style.setProperty("--web-wash",o),m.style.setProperty("--card-background",r?o:l),m.style.setProperty("--overlay-alpha-80","#f4f4f463"),m.style.setProperty("--secondary-text","#373839"),r&&(m.style.setProperty("--secondary-text","#000000"),m.style.setProperty("--shadow-1",o)))}}))}));window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",h),k.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0})}()})();