<commit_before>// Author: <NAME>
// Email: <EMAIL>
// License: MIT license

function MatchingKeyAndUrl(text, tab) {
    if ((tab.url.search(text) > -1) ||  //general rules
        (tab.title.search(text) > -1) ||  //general rules
        (text == 'm' && tab.url.search("mail.google.com") > -1) ||
        (text == 'c' && tab.title.search("Google Calendar") > -1) ||
        (text == 'i' && tab.url.search("inbox.google.com") > -1) ||
        (text == 'dr' && tab.url.search("drive.google.com") > -1) ||
        (text == 'y' && tab.url.search("youtube.com") > -1) ||
        (text == 'map' && tab.title.search("Google Map") > -1))
    {
        return true;
    }
    return false;
}

function TabExists(currentWindow, text) {
    for (var i = 0; i < currentWindow.tabs.length; i++) {
        if (MatchingKeyAndUrl(text, currentWindow.tabs[i])) {
            return {exist: true, id: currentWindow.tabs[i].id};
        }
    }
    return {exist: false, id: -1};
}

function zmdMain(text) {
    console.log('inputEntered: ' + text);
    chrome.windows.getCurrent({populate: true}, function(currentWindow) {
        var x = new TabExists(currentWindow, text);
        if (x.exist) {
            chrome.tabs.update(x.id, {active:true});
        }
        else { 
            // Tab does not exist.
            if (text == 'm') {
                chrome.tabs.update(null, {url:"https://mail.google.com"});
            } else if (text == 'c') {
                chrome.tabs.update(null, {url:"https://calendar.google.com"});
            } else if (text == 'w') {
                chrome.tabs.update(null, {url:"http://www.weibo.com"});
            } else if (text == 'f') {
                chrome.tabs.update(null, {url:"https://www.facebook.com"});
            } else if (text == 'dr') {
                chrome.tabs.update(null, {url:"https://drive.google.com"});
            } else if (text == 'y') {
                chrome.tabs.update(null, {url:"https://www.youtube.com"});<commit_msg>remove keyword matching in general rule<commit_after>// Author: <NAME>
// Email: <EMAIL>
// License: MIT license

var KeyWord = [
'm',
'c',
'i',
'w',
'dr',
'y',
'map',
'key'
]

function MatchingKeyAndUrl(text, tab) {
    if ((text == 'm' && tab.url.search("mail.google.com") > -1) ||
        (text == 'c' && tab.title.search("Google Calendar") > -1) ||
        (text == 'w' && tab.url.search("weibo.com") > -1) ||
        (text == 'i' && tab.url.search("inbox.google.com") > -1) ||
        (text == 'dr' && tab.url.search("drive.google.com") > -1) ||
        (text == 'y' && tab.url.search("youtube.com") > -1) ||
        (text == 'map' && tab.title.search("Google Map") > -1))
    {
        return true;
    }
    if (KeyWord.indexOf(text) == -1) {
        // Not keyword
        if ((tab.url.search(text) > -1) || (tab.title.search(text) > -1)) {
            return true;
        }
    }
    return false;
}

function TabExists(currentWindow, text) {
    for (var i = 0; i < currentWindow.tabs.length; i++) {
        if (MatchingKeyAndUrl(text, currentWindow.tabs[i])) {
            return {exist: true, id: currentWindow.tabs[i].id};
        }
    }
    return {exist: false, id: -1};
}

function zmdMain(text) {
    console.log('inputEntered: ' + text);
    chrome.windows.getCurrent({populate: true}, function(currentWindow) {
        var x = new TabExists(currentWindow, text);
        if (x.exist) {
            chrome.tabs.update(x.id, {active:true});
        }
        else { 
            // Tab does not exist.
            if (text == 'm') {
                chrome.tabs.update(null, {url:"https://mail.google.com"});
            } else if (text == 'c') {
                chrome.tabs.update(null, {url:"https://calendar.google.com"});
            } else if (text == 'w') {
                chrome.tabs.update(null, {url:"http://www.weibo.com"});
            } else if (text == 'i') {
                chrome.tabs.update(null, {url:"https://inbox.google.com"});
            } else if (text == 'dr') {
                chrome.tabs.update(null, {url:"https://drive.google.com"});
            } else if (text == 'y') {
                chrome.tabs.update(null, {url:"https://www.youtube.com"});
{'fraction_non_alphanumeric': 0.20311377245508982, 'fraction_numerical': 0.005269461077844311, 'mean_word_length': 2.0548646671543525, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 24, 'https://': 10, 'lorem ipsum': 0, 'www.': 5, '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': '3347254', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1370, 'n_words': 280}