-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added feature of changin background to any image of internet
- Loading branch information
1 parent
7524f80
commit 80492d4
Showing
10 changed files
with
236 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
.change-bg-video{ | ||
|
||
width: 100%; | ||
height: 100%; | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
z-index: 8; | ||
|
||
} | ||
|
||
.change-bg-video iframe{ | ||
|
||
width: 100%; | ||
height: 100%; | ||
|
||
} | ||
|
||
|
||
|
||
#app *:not(.change-bg-video){ | ||
|
||
z-index: 10; | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,55 @@ | ||
|
||
socket_tasks = { | ||
'updateLocalStorage': updateStorage, | ||
'getItemFromLocalStorate': getFromStorage | ||
}; | ||
|
||
async function sendMessageToActiveTab(messageArgs, callback) { | ||
let queryOptions = { active: true, currentWindow: true }; | ||
let tab = await chrome.tabs.query(queryOptions); | ||
chrome.tabs.sendMessage(tab[0].id, messageArgs, callback); | ||
|
||
return true; | ||
|
||
} | ||
|
||
|
||
function updateStorage(data){ | ||
if(data){ | ||
for (const [key, value] of Object.entries(data)) { | ||
localStorage.setItem(key, value); | ||
} | ||
|
||
} | ||
|
||
return false; | ||
} | ||
chrome.runtime.onConnect.addListener(function(port) { | ||
port.onMessage.addListener(async function(msg) { | ||
if (msg.task in socket_tasks){ | ||
rslt = await socket_tasks[msg.task](...msg.args); | ||
port.postMessage({result: rslt, task: msg.task}); | ||
} | ||
}); | ||
}) | ||
|
||
function getFromStorage(storageElement){ | ||
if(storageElement){ | ||
return localStorage.getItem(storageElement); | ||
} | ||
return false; | ||
|
||
const convertImageToBase64Image = async (url) => { | ||
const data = await fetch(url) | ||
const blob = await data.blob(); | ||
const reader = new FileReader(); | ||
reader.readAsDataURL(blob); | ||
reader.onload = async () => { | ||
const base64data = await reader.result; | ||
return await sendMessageToActiveTab({ task: 'handleBgChanging', args: [base64data] }, _ => {console.log('must to update')}) | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
socket_tasks = { | ||
'convertImageToBase64': convertImageToBase64Image, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
|
||
function handleBgChange(imageUrl){ | ||
|
||
updateStorage({ | ||
'voxiomBgImage': imageUrl | ||
}) | ||
updateHomePageBg(); | ||
|
||
|
||
} | ||
|
||
|
||
function handleResetBg(base64Image){ | ||
|
||
updateStorage({ | ||
'voxiomBgImage': base64Image | ||
}) | ||
|
||
updateHomePageBg(); | ||
|
||
} | ||
|
||
|
||
|
||
function updateHomePageBg() { | ||
bgImageFromCache = getFromStorage('voxiomBgImage'); | ||
|
||
if(bgImageFromCache === undefined) return false; | ||
|
||
bgImageChangeStyles = { | ||
|
||
"background": `url(${bgImageFromCache}) no-repeat center !important`, | ||
"background-size": `cover !important` | ||
}; | ||
|
||
|
||
objectToTagStyles('.bNczYf', bgImageChangeStyles); | ||
} | ||
|
||
updateHomePageBg(); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
async function convertImage(imgUrl){ | ||
base64Image = await port.postMessage({ task: 'convertImageToBase64', args: [imgUrl] }); | ||
return base64Image; | ||
|
||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters