-
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.
refactored to easily add new features, add new feature, adding custom…
… crosshair, only not for sniper rifle, since in game it can be done via game settings.
- Loading branch information
1 parent
f2b3d25
commit 6b8f9c6
Showing
12 changed files
with
349 additions
and
32 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 |
---|---|---|
@@ -1,2 +1,9 @@ | ||
|
||
|
||
#app > div{ | ||
|
||
z-index: 2; | ||
|
||
} | ||
|
||
|
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
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,118 @@ | ||
|
||
|
||
function handleCrosshairChanging(base64Img){ | ||
|
||
if(!base64Img){ | ||
base64Img = ''; | ||
} | ||
|
||
|
||
|
||
updateStorage({ | ||
'voxiomDefaultCrosshair': base64Img | ||
}) | ||
updateCrossHair(base64Img); | ||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
function updateCrossHair(base64Img) { | ||
|
||
existedCrossHairs = getElements('.custom-crosshair'); | ||
if(existedCrossHairs.length > 0){ | ||
existedCrossHairs.forEach(crosshair => { | ||
if(crosshair){ | ||
try{ | ||
crosshair.remove(); | ||
} catch(e){ | ||
|
||
} | ||
} | ||
}) | ||
} | ||
|
||
if(!base64Img){ | ||
return false; | ||
} | ||
|
||
|
||
newCrossHair = document.createElement("img"); | ||
addClass(newCrossHair, 'custom-crosshair'); | ||
newCrossHair.src = base64Img; | ||
newCrossHair.onload = _ => { | ||
crossHairStyle = { | ||
|
||
"position": 'fixed !important', | ||
"top": '50%', | ||
"left": '50%', | ||
"transform": 'translate(-50%, -50%)', | ||
"z-index": '1', | ||
"opacity": '1', | ||
|
||
}; | ||
|
||
newCrossHair.style.cssText = objectToCssTextStyles(crossHairStyle); | ||
|
||
appendToElement('#app', newCrossHair); | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
waitForElm('.sc-frCSdB').then((elm) => { | ||
customGameSniperCrossHair = getElement('.sc-frCSdB'); | ||
|
||
if(customGameSniperCrossHair){ | ||
|
||
const customCrossHairconfig = { | ||
attributes: true | ||
}; | ||
const customCrossHairCallback = function(mutationsList, observer) { | ||
for (let mutation of mutationsList) { | ||
if (mutation.type === 'attributes') { | ||
if(customGameSniperCrossHair.style.opacity == '1'){ | ||
getElement('.custom-crosshair').style.opacity = '0'; | ||
} else{ | ||
getElement('.custom-crosshair').style.opacity = '1'; | ||
} | ||
|
||
} | ||
} | ||
}; | ||
|
||
const customCrossHairObserver = new MutationObserver(customCrossHairCallback); | ||
|
||
customCrossHairObserver.observe(customGameSniperCrossHair, customCrossHairconfig); | ||
|
||
} | ||
|
||
}); | ||
|
||
|
||
|
||
function launchUpdatingCrossHair() { | ||
bgImageFromCache = getFromStorage('voxiomDefaultCrosshair'); | ||
if(bgImageFromCache === undefined) return updateCrossHair(false); | ||
updateCrossHair(bgImageFromCache); | ||
} | ||
|
||
launchUpdatingCrossHair(false); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
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,36 @@ | ||
|
||
base64String = ''; | ||
async function crosshairUpdateHandler(fileInput){ | ||
if(!fileInput){ | ||
try{ | ||
return await sendMessageToActiveTab({ task: 'handleCrosshairChanging', args: [false] }, _ => {console.log('must to update')}) | ||
} catch(e){ | ||
|
||
} | ||
} | ||
file = fileInput['files'][0]; | ||
|
||
const reader = new FileReader(); | ||
|
||
reader.onload = async function () { | ||
base64String = reader.result; | ||
try{ | ||
return await sendMessageToActiveTab({ task: 'handleCrosshairChanging', args: [reader.result] }, _ => {console.log('must to update')}) | ||
} catch(e){ | ||
|
||
} | ||
|
||
}; | ||
|
||
reader.readAsDataURL(file); | ||
return base64String; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.