Skip to content

Instantly share code, notes, and snippets.

@swcho
Created September 19, 2024 12:04
Show Gist options
  • Save swcho/36a9a36ca5631acb4cba1f3386591df9 to your computer and use it in GitHub Desktop.
Save swcho/36a9a36ca5631acb4cba1f3386591df9 to your computer and use it in GitHub Desktop.
settings.showModeStatus = false;
settings.editableBodyCare = false;
// console.log('SurfingKeys', api)
// getEventListeners(window).copy?.forEach(({ listener }) => window.removeEventListener('copy', listener))
// chrome.debugger.sendCommand({ tabId }, "Target.setAutoAttach", {
// autoAttach: true,
// waitForDebuggerOnStart: false,
// flatten: true,
// filter: [{ type: "iframe", exclude: false }]
// }).then(console.log);
api.mapkey('ymd', 'Copy a link as markdown', function () {
api.Hints.create('*[href]', function (element) {
api.Clipboard.write(`[${element.innerText}](${element.href})`);
});
});
api.mapkey('ymt', 'Copy current tab as markdown', function () {
api.Clipboard.write(`[${document.title}](${location.href})`);
});
// api.mapkey('h', 'Hover item', function() {
// api.Hints.create('*[href]', function(element) {
// });
// });
api.mapkey('af', 'Active focuse', function () {
const targets = [...document.querySelectorAll('*')].filter((elem) => {
return elem.scrollHeight > elem.clientHeight + 10;
});
// const targets = Mode.getScrollableElements()
api.Hints.create(targets, function (elm) {
// console.log({ elm, api });
elm = elm.children[0];
if (elm.scrollIntoViewIfNeeded) {
elm.scrollIntoViewIfNeeded();
} else if (!api.isElementPartiallyInViewport(elm, ignoreSize)) {
elm.scrollIntoView();
}
});
});
api.map('i', 'ii');
api.unmap('i');
api.map('d', 'j');
api.map('e', 'k');
api.imap(';;', '<Esc>'); // press comma twice to leave current input box.
api.iunmap('<Esc>'); // press comma twice to leave current input box.
api.mapkey('ii', 'Input', function () {
api.Hints.create(
'input:not([type=submit]), textarea, *[contenteditable=true], *[role=textbox], select, div.ace_cursor',
api.Hints.dispatchMouseClick,
);
});
api.mapkey('im', 'Monaco input', function () {
const selector = 'textarea.monaco-mouse-cursor-text';
const target = document.querySelector(selector);
api.Hints.dispatchMouseClick(target);
});
api.mapkey('in', 'Monaco input with vim', function () {
const selector = 'textarea.monaco-mouse-cursor-text';
const target = document.querySelector(selector);
api.Front.showEditor(target);
});
let el_prev_open;
// api.map('F', 'gf');
api.mapkey('F', 'custom', function () {
// api.Hints.create("", api.Hints.dispatchMouseClick, {tabbed: true, active: true});
api.Hints.create(
'',
(...args) => {
if (el_prev_open) {
el_prev_open.classList.remove('sk_opened');
el_prev_open.style.borderBottom = '';
}
const el = args[0];
// console.log(el)
el.style.borderBottom = '2px solid red';
el.classList.add('sk_opened');
el_prev_open = el;
api.Hints.dispatchMouseClick(...args);
// RUNTIME("nextTab");
},
{ tabbed: true, active: true },
);
});
api.unmap('1', /flash-man-9d6a2.web.app/);
api.unmap('2', /flash-man-9d6a2.web.app/);
api.unmap('3', /flash-man-9d6a2.web.app/);
api.unmap('4', /flash-man-9d6a2.web.app/);
api.unmap('d', /mail.navercorp.com/);
api.unmap('t', /youtube.com/);
api.unmap('f', /youtube.com/);
api.unmap('>', /youtube.com/);
api.unmap('<', /youtube.com/);
api.unmap('x', /mail.google.com/);
api.unmapAllExcept([], /colab.research.google.com/);
api.unmapAllExcept([], /localhost/);
// api.unmapAllExcept([], /.*.aida.navercorp.com/)
// an example to create a new mapping `ctrl-y`
api.mapkey('<ctrl-y>', 'Show me the money', function () {
Front.showPopup(
'a well-known phrase uttered by characters in the 1996 film Jerry Maguire (Escape to close).',
);
});
settings.digitForRepeat = false;
// an example to replace `T` with `gt`, click `Default mappings` to see how `T` works.
// api.map('gt', 'T');
// an example to remove mapkey `Ctrl-i`
// api.unmap('<ctrl-i>');
// set theme
settings.theme = `
.sk_theme {
font-family: Input Sans Condensed, Charcoal, sans-serif;
font-size: 10pt;
background: #24272e;
color: #abb2bf;
}
.sk_theme tbody {
color: #fff;
}
.sk_theme input {
color: #d0d0d0;
}
.sk_theme .url {
color: #61afef;
}
.sk_theme .annotation {
color: #56b6c2;
}
.sk_theme .omnibar_highlight {
color: #528bff;
}
.sk_theme .omnibar_timestamp {
color: #e5c07b;
}
.sk_theme .omnibar_visitcount {
color: #98c379;
}
.sk_theme #sk_omnibarSearchResult ul li:nth-child(odd) {
background: #303030;
}
.sk_theme #sk_omnibarSearchResult ul li.focused {
background: #3e4452;
}
#sk_status, #sk_find {
font-size: 20pt;
}
#sk_status {
opacity: 0.3;
}
.sk_opened {
border-bottom: 2px solid red;
}
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment