<commit_before>const electronLocalshortcut = require('electron-localshortcut');
const {globalShortcut} = require('electron');
var {ipcMain} = require('electron');

let win;

var map = {
    'Ctrl+N': nextClicked,
    'Ctrl+P': prevClicked,
    'Space': pauseClicked,
};

var globalMap = {
    'MediaNextTrack': nextClicked,
    'MediaPreviousTrack': prevClicked,
    'MediaPlayPause': pauseClicked,
    'Ctrl+3': likeClicked,
    'Ctrl+4': repeatClicked
};

var repeatClickedJScript = `
    var repeatBtn = document.getElementsByClassName('repeatControl')[0];
    repeatBtn.click();
    if(repeatBtn.className.includes("m-none")){
        new Notification('Repeat Mode',{
            body:'Repeat has been disabled',
            silent:true
        });
    }else{
        new Notification('Repeat Mode',{
            body:'Repeat has been enabled',
            silent:true
        });
    }
`;

var likeClicked = `
    var likeBtn = document.getElementsByClassName('playbackSoundBadge__like')[0];
    var title = document.getElementsByClassName('playbackSoundBadge__title')[0].title;
    var imageUrl = document.getElementsByClassName('playbackSoundBadge__avatar')[0].children[0].children[0].style.backgroundImage;
    imageUrl = imageUrl.substring(5,imageUrl.length-2);

    likeBtn.click();
    if(likeBtn.className.includes("sc-button-selected")){
        new Notification('Liked',{
            body:title,
            silent:true,
            icon:imageUrl
        });
    }else{
        new Notification('Disliked',{
            body:title,
            silent:true,
            icon:imageUrl
        });
    }
`;


function likeClicked() {
    win.webContents.executeJavaScript(likeClicked);
}

function nextClicked() {
    win.webContents.executeJavaScript("document.getElementsByClassName('playControls__next')[0].click()");
}

function prevClicked() {
    win.webContents.executeJavaScript("document.getElementsByClassName('playControls__prev')[0].click()");
}

function pauseClicked() {
    win.webContents.executeJavaScript("document.getElementsByClassName('playControls__play')[0].click()");
}

function repeatClicked() {
    win.webContents.executeJavaScript(repeatClickedJScript);
}

function initShorts(window) {
    win = window;
    for (let key in map) {
        electronLocalshortcut.register(win, key, () => {
            map[key].call();
        });
    }
    for (let key in globalMap) {
        globalShortcut.register(key, () => {
            globalMap[key].call();
        })
    }
}

function destShorts() {
    win = null;
    electronLocalshortcut.unregisterAll(win);
}

module.exports = {
    initShorts,
    destShorts,
    likeClicked,
    nextClicked,
    prevClicked,
    pauseClicked,
    repeatClicked
};<commit_msg>Notify only when out of focus<commit_after>const electronLocalshortcut = require('electron-localshortcut');
const {globalShortcut} = require('electron');
var {ipcMain} = require('electron');

let win;

var map = {
    'Ctrl+N': nextClicked,
    'Ctrl+P': prevClicked,
    'Space': pauseClicked,
    'F5': reloadWind
};

var globalMap = {
    'MediaNextTrack': nextClicked,
    'MediaPreviousTrack': prevClicked,
    'MediaPlayPause': pauseClicked,
    'Ctrl+3': likeClicked,
    'Ctrl+4': repeatClicked
};

var repeatClickedJScript = `
    var repeatBtn = document.getElementsByClassName('repeatControl')[0];
    repeatBtn.click();
`;

var repeatClickedNotify = `
    if(repeatBtn.className.includes("m-none")){
        new Notification('Repeat : Disabled',{
            body:'Repeat has been disabled',
            silent:true
        });
    }else{
        new Notification('Repeat : Enabled',{
            body:'Repeat has been enabled',
            silent:true
        });
    }
`;

var likeClicked = `
    var likeBtn = document.getElementsByClassName('playbackSoundBadge__like')[0];
    likeBtn.click();
`;

var likeClickedNotify = `
    var title = document.getElementsByClassName('playbackSoundBadge__title')[0].title;
    var imageUrl = document.getElementsByClassName('playbackSoundBadge__avatar')[0].children[0].children[0].style.backgroundImage;
    imageUrl = imageUrl.substring(5,imageUrl.length-2);
    if(likeBtn.className.includes("sc-button-selected")){
        new Notification('Liked',{
            body:title,
            silent:true,
            icon:imageUrl
        });
    }else{
        new Notification('Disliked',{
            body:title,
            silent:true,
            icon:imageUrl
        });
    }
`;

function reloadWind(){
    win.reload();
}

function likeClicked() {
    var execJs=likeClicked;
    if(!win.isFocused()){
        execJs+=likeClickedNotify;
    }
    win.webContents.executeJavaScript(execJs);
}

function nextClicked() {
    win.webContents.executeJavaScript("document.getElementsByClassName('playControls__next')[0].click()");
}

function prevClicked() {
    win.webContents.executeJavaScript("document.getElementsByClassName('playControls__prev')[0].click()");
}

function pauseClicked() {
    win.webContents.executeJavaScript("document.getElementsByClassName('playControls__play')[0].click()");
}

function repeatClicked() {
    var execJs=repeatClickedJScript;
    if(!win.isFocused()){
        execJs+=repeatClickedNotify;
    }
    win.webContents.executeJavaScript(execJs);
}

function initShorts(window) {
    win = window;
    for (let key in map) {
        electronLocalshortcut.register(win, key, () => {
            map[key].call();
        });
    }
    for (let key in globalMap) {
        globalShortcut.register(key, () => {
            globalMap[key].call();
        })
    }
}

function destShorts() {
    win = null;
    electronLocalshortcut.unregisterAll(win);
}

module.exports = {
    initShorts,
    destShorts,
    likeClicked,
    nextClicked,
    prevClicked,
    pauseClicked,
    repeatClicked
};
{'fraction_non_alphanumeric': 0.13421323277339733, 'fraction_numerical': 0.004628042509427494, 'mean_word_length': 3.252915451895044, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5507534', 'n_tokens_mistral': 1800, 'n_tokens_neox': 1791, 'n_words': 278}