brookhong / Surfingkeys

Map your keys for web surfing, expand your browser with javascript and keyboard.
https://chrome.google.com/webstore/detail/surfingkeys/gfbliohnnapiefjpjlpjnehglfpaknnc
MIT License
5.32k stars 477 forks source link

whats the command to open a link/URL in the current tab and not new tab (tabOpenLink) #148

Closed zeltak closed 7 years ago

zeltak commented 7 years ago

Hi im looking to open a link in the current tab and not new tab (tabOpenLink)

i want to change this line

"tabOpenLink('" + urls[key] + "')"

top open in the current tab

best

Z

brookhong commented 7 years ago

Your could read the default mappings in settings, and figure it out by yourself without much effort.

function openLinkInCurrentTab(url) {
    RUNTIME("openLink", {
        tab: {
            tabbed: false
        },
        url: url
    });
}

openLinkInCurrentTab("https://github.com/");
zeltak commented 7 years ago

hmm sorry again for being a pain but i really cant get it to work :) i apologize in advance for my pathetic coding skills and really appreciate your help :)

i currently have this setup (which you helped me with greatly) which works great :+1:

/// quicklinks new tab  
var favorites = function(prefix, urls) {
    for (var key in urls) {
        mapkey(
            prefix + key,
            'favorite:' + urls[key],
            "tabOpenLink('" + urls[key] + "')"
        )
    }
}

favorites('gn', {
    0:  'http://10.0.0.2:9091/transmission/web/', 
    1:  'https://mail.google.com/',
    2:  'http://www.google.com/calendar',
    3:  'https://www.google.com/contacts/#contacts',
    4:  'https://ttrss.server-speed.net/#f=-3am', 
})

i wanted to have an additional key to open in current tab instead of new tab. i thought this should do it

/// quicklinks new tab  
var favorites2 = function(prefix, urls) {
    for (var key in urls) {
        mapkey(
            prefix + key,
            'favorite:' + urls[key],
            ""openLinkInCurrentTab('" + urls[key] + "')"
        )
    }
}

favorites2('go', {
    0:  'http://10.0.0.2:9091/transmission/web/', 
    1:  'https://mail.google.com/',
    2:  'http://www.google.com/calendar',
    3:  'https://www.google.com/contacts/#contacts',
    4:  'https://ttrss.server-speed.net/#f=-3am', 
})

but that dosent really seem to work. if you can be bothered ill understand :D but would be great to get it to work. i can also add it to a wiki if you want

best

Z

brookhong commented 7 years ago

Full code is here.

BTW, you could not use go, as it is already use in default mappings.

function openLinkInCurrentTab(url) {
    RUNTIME("openLink", {
        tab: {
            tabbed: false
        },
        url: url
    });
}

var favorites2 = function(prefix, urls) {
    for (var key in urls) {
        mapkey(
            prefix + key,
            'favorite:' + urls[key],
            "openLinkInCurrentTab('" + urls[key] + "')"
        )
    }
}

favorites2('gj', {
    0:  'http://10.0.0.2:9091/transmission/web/', 
    1:  'https://mail.google.com/',
    2:  'http://www.google.com/calendar',
    3:  'https://www.google.com/contacts/#contacts',
    4:  'https://ttrss.server-speed.net/#f=-3am', 
})
zeltak commented 7 years ago

thx so much again, for the life of me i cant get it to work

here attached is my current config

.surfingkeys.js.zip

thx again so much, really appreciated

Z