Skip to content

Commit

Permalink
add effect and save position
Browse files Browse the repository at this point in the history
  • Loading branch information
GregVido committed Dec 3, 2022
1 parent 7f7d5c6 commit 6fe0da8
Show file tree
Hide file tree
Showing 7 changed files with 362 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
52 changes: 48 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,52 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

const electron = require('electron');
const { PARAMS, VALUE, MicaBrowserWindow } = require('mica-electron');
const path = require('path');
const fs = require('fs');

const FOLDER_CONFIG = path.join(process.env.APPDATA, 'MicaSnap');
const FILE_CONFIG = path.join(process.env.APPDATA, 'MicaSnap') + "/config.json";

if (!fs.existsSync(FOLDER_CONFIG))
fs.mkdirSync(FOLDER_CONFIG);

if (!fs.existsSync(FILE_CONFIG))
fs.writeFileSync(FILE_CONFIG, JSON.stringify({ background: PARAMS.BACKGROUND.MICA }, null, 4));

let SETTING = require(FILE_CONFIG);

let ipcMain = electron.ipcMain;

electron.app.commandLine.appendSwitch("enable-transparent-visuals");

electron.app.on('ready', () => {
let background = SETTING.background;
let theme = VALUE.THEME.AUTO;

const win = new MicaBrowserWindow({
width: 1280,
height: 720,
effect: PARAMS.BACKGROUND.MICA,
effect: background,
theme: VALUE.THEME.AUTO,
autoHideMenuBar: true,
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
}
},
icon: path.join('icon', 'app.ico')
});

if(!SETTING.bounds) {
SETTING.bounds = win.getBounds();
fs.writeFileSync(FILE_CONFIG, JSON.stringify(SETTING, null, 4));
}
else
win.setBounds(SETTING.bounds);

win.loadURL('https://web.snapchat.com/', {
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.62'
});
Expand All @@ -46,13 +68,35 @@ electron.app.on('ready', () => {
win.show();
});

win.on('close', () => {
SETTING.bounds = win.getBounds();
fs.writeFileSync(FILE_CONFIG, JSON.stringify(SETTING, null, 4));
});

ipcMain.on('getBackground', (event) => {
event.returnValue = background
});

ipcMain.on('theme', (event, id) => {
const webContents = event.sender;
const win = MicaBrowserWindow.fromWebContents(webContents);

if (id == 0)
win.setVisualEffect(PARAMS.BACKGROUND.MICA, VALUE.THEME.LIGHT);
theme = VALUE.THEME.LIGHT;
else if (id == 1)
win.setVisualEffect(PARAMS.BACKGROUND.MICA, VALUE.THEME.DARK);
theme = VALUE.THEME.DARK;

win.setVisualEffect(background, theme);
});

ipcMain.on('effect', (event, id) => {
const webContents = event.sender;
const win = MicaBrowserWindow.fromWebContents(webContents);

background = id;
win.setVisualEffect(background, theme);

SETTING.background = id;
fs.writeFileSync(FILE_CONFIG, JSON.stringify(SETTING, null, 4));
});
});
Binary file added icon/app.ico
Binary file not shown.
61 changes: 61 additions & 0 deletions injector/a.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<div id="downshift-1-menu" role="listbox" aria-labelledby="downshift-1-label" tabindex="-1" class="hrl98 bfo2B"
style="inset-inline: 0px;">
<div class="VoxbS">
<div class="CeO6L" role="option" aria-selected="false" id="downshift-1-item-0">
<div class="KT6b1">
<div class="PXgY2">Thème</div>
<div class="tvg6i">Système</div>
</div>
</div>
<div class="CeO6L" role="option" aria-selected="false" id="downshift-1-item-9">
<div class="KT6b1">
<div class="PXgY2">Effet</div>
<div class="tvg6i">Mica</div>
</div>
</div>
<div class="CeO6L" role="option" aria-selected="false" id="downshift-1-item-1">
<div class="KT6b1">
<div class="PXgY2">Désactiver les effets sonores</div>
</div>
</div>
<div class="CeO6L" role="option" aria-selected="false" id="downshift-1-item-2"><a class="pktQ3 hQMCs"><span
class="lmyVJ">Désactiver les notifications</span></a></div>
<div class="CeO6L" role="option" aria-selected="false" id="downshift-1-item-3"><a class="pktQ3 hQMCs"><span
class="lmyVJ">Centre d'aide</span><span class="C8gWe"><svg width="16" height="16"
viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="SksVe">
<path fill-rule="evenodd" clip-rule="evenodd"
d="M8.8 3.1a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v3.655a.75.75 0 1 1-1.5 0V4.91L7.925 9.287a.75.75 0 0 1-1.06-1.06L11.24 3.85H9.55a.75.75 0 0 1-.75-.75Zm-4.75-.7a1.7 1.7 0 0 0-1.7 1.7v8a1.7 1.7 0 0 0 1.7 1.7h8a1.7 1.7 0 0 0 1.7-1.7V9.85a.7.7 0 1 0-1.4 0v2.25a.3.3 0 0 1-.3.3h-8a.3.3 0 0 1-.3-.3v-8a.3.3 0 0 1 .3-.3h2.6a.7.7 0 1 0 0-1.4h-2.6Z"
fill="#4E565F"></path>
</svg></span></a></div>
<div class="CeO6L" role="option" aria-selected="false" id="downshift-1-item-4"><a class="pktQ3 hQMCs"><span
class="lmyVJ">Signaler un problème</span><span class="C8gWe"><svg width="16" height="16"
viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="SksVe">
<path fill-rule="evenodd" clip-rule="evenodd"
d="M8.8 3.1a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v3.655a.75.75 0 1 1-1.5 0V4.91L7.925 9.287a.75.75 0 0 1-1.06-1.06L11.24 3.85H9.55a.75.75 0 0 1-.75-.75Zm-4.75-.7a1.7 1.7 0 0 0-1.7 1.7v8a1.7 1.7 0 0 0 1.7 1.7h8a1.7 1.7 0 0 0 1.7-1.7V9.85a.7.7 0 1 0-1.4 0v2.25a.3.3 0 0 1-.3.3h-8a.3.3 0 0 1-.3-.3v-8a.3.3 0 0 1 .3-.3h2.6a.7.7 0 1 0 0-1.4h-2.6Z"
fill="#4E565F"></path>
</svg></span></a></div>
<div class="CeO6L" role="option" aria-selected="false" id="downshift-1-item-5"><a class="pktQ3 hQMCs"><span
class="lmyVJ">J'ai une suggestion.</span><span class="C8gWe"><svg width="16" height="16"
viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="SksVe">
<path fill-rule="evenodd" clip-rule="evenodd"
d="M8.8 3.1a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v3.655a.75.75 0 1 1-1.5 0V4.91L7.925 9.287a.75.75 0 0 1-1.06-1.06L11.24 3.85H9.55a.75.75 0 0 1-.75-.75Zm-4.75-.7a1.7 1.7 0 0 0-1.7 1.7v8a1.7 1.7 0 0 0 1.7 1.7h8a1.7 1.7 0 0 0 1.7-1.7V9.85a.7.7 0 1 0-1.4 0v2.25a.3.3 0 0 1-.3.3h-8a.3.3 0 0 1-.3-.3v-8a.3.3 0 0 1 .3-.3h2.6a.7.7 0 1 0 0-1.4h-2.6Z"
fill="#4E565F"></path>
</svg></span></a></div>
<div class="CeO6L" role="option" aria-selected="false" id="downshift-1-item-6"><a class="pktQ3 hQMCs"><span
class="lmyVJ">Paramètres du compte</span><span class="C8gWe"><svg width="16" height="16"
viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="SksVe">
<path fill-rule="evenodd" clip-rule="evenodd"
d="M8.8 3.1a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v3.655a.75.75 0 1 1-1.5 0V4.91L7.925 9.287a.75.75 0 0 1-1.06-1.06L11.24 3.85H9.55a.75.75 0 0 1-.75-.75Zm-4.75-.7a1.7 1.7 0 0 0-1.7 1.7v8a1.7 1.7 0 0 0 1.7 1.7h8a1.7 1.7 0 0 0 1.7-1.7V9.85a.7.7 0 1 0-1.4 0v2.25a.3.3 0 0 1-.3.3h-8a.3.3 0 0 1-.3-.3v-8a.3.3 0 0 1 .3-.3h2.6a.7.7 0 1 0 0-1.4h-2.6Z"
fill="#4E565F"></path>
</svg></span></a></div>
<div class="CeO6L" role="option" aria-selected="false" id="downshift-1-item-7"><a class="pktQ3 hQMCs"><span
class="lmyVJ">Politique de confidentialité</span><span class="C8gWe"><svg width="16" height="16"
viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="SksVe">
<path fill-rule="evenodd" clip-rule="evenodd"
d="M8.8 3.1a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v3.655a.75.75 0 1 1-1.5 0V4.91L7.925 9.287a.75.75 0 0 1-1.06-1.06L11.24 3.85H9.55a.75.75 0 0 1-.75-.75Zm-4.75-.7a1.7 1.7 0 0 0-1.7 1.7v8a1.7 1.7 0 0 0 1.7 1.7h8a1.7 1.7 0 0 0 1.7-1.7V9.85a.7.7 0 1 0-1.4 0v2.25a.3.3 0 0 1-.3.3h-8a.3.3 0 0 1-.3-.3v-8a.3.3 0 0 1 .3-.3h2.6a.7.7 0 1 0 0-1.4h-2.6Z"
fill="#4E565F"></path>
</svg></span></a></div>
<div class="CeO6L" role="option" aria-selected="false" id="downshift-1-item-8"><a
class="pktQ3 SnUwI hQMCs"><span class="lmyVJ">Déconnexion</span></a></div>
</div>
</div>
Loading

0 comments on commit 6fe0da8

Please sign in to comment.