Facebook custom background

Change background image with Base64 conversion

目前为 2025-02-06 提交的版本。查看 最新版本

// ==UserScript==
// @name         Facebook custom background
// @namespace    http://tampermonkey.net/
// @version      0.0.2
// @description  Change background image with Base64 conversion
// @author       You
// @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,n){var t=indexedDB.open("ImageStorageDB",1);t.onerror=function(e){n("Error opening IndexedDB")},t.onsuccess=function(n){e(n.target.result)},t.onupgradeneeded=function(e){e.target.result.createObjectStore("images",{keyPath:"id"}).createIndex("base64","base64",{unique:!1})}}))}!function(){var n=document.createElement("div"),t=document.createElement("div"),o=document.createElement("input"),r="darken",a="#2f2f2fa6",c="#25272880",i="lighten",d="#d7d4d469",u="#ffffff99",s=function(e){n.style.opacity=0,setTimeout((function(){n.style.backgroundImage="url(".concat(e,")"),n.style.opacity=1}),0)};o.type="file",o.accept="image/png, image/jpeg, image/jpg",o.style.display="none";var g={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(n.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(t.style,g),document.body.appendChild(n),document.body.appendChild(t),document.body.appendChild(o),o.addEventListener("change",(function(n){var t=n.target.files[0];t&&function(e,n){var t=new FileReader;t.onloadend=function(){n(t.result)},t.readAsDataURL(e)}(t,(function(n){s(n),function(n){e().then((function(e){var t=e.transaction("images","readwrite"),o=t.objectStore("images"),r={id:"backgroundImage",base64:n};o.put(r),t.oncomplete=function(){console.log("Image saved to IndexedDB")},t.onerror=function(){console.error("Error saving image to IndexedDB")}})).catch((function(e){return console.error(e)}))}(n)}))})),t.addEventListener("click",(function(){o.click()})),new Promise((function(n,t){e().then((function(e){var o=e.transaction("images","readonly").objectStore("images").get("backgroundImage");o.onsuccess=function(e){e.target.result?n(e.target.result.base64):t("No image found")},o.onerror=function(){t("Error retrieving image from IndexedDB")}})).catch((function(e){return t(e)}))})).then((function(e){s(e)})).catch((function(e){console.error(e)})),new MutationObserver((function(e){e.forEach((function(e){if(e.target===document.documentElement&&"class"===e.attributeName){var t=document.documentElement.classList.contains("__fb-dark-mode");n.style.backgroundBlendMode=t?r:i,n.style.backgroundColor=t?a:d,document.documentElement.style.setProperty("--card-background",t?c:u)}}))})).observe(document.documentElement,{attributes:!0})}()})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址