Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- globalSearch () {
- const globalSearchInput = document.getElementById('tc-global-search-input'),
- globalSearchOuter = document.getElementById('tc-global-search-outer');
- if (!globalSearchOuter) return;
- function sendInput() {
- const quickSwitcherInput = document.querySelector('.input-MwQhcX');
- function sendCtrlK() {
- var options = { key: "k", code: "k", which: 75, keyCode: 75, "ctrlKey": true, bubbles: true };
- var down = new KeyboardEvent("keydown", options);
- Object.defineProperty(down, "keyCode", {value: 75});
- Object.defineProperty(down, "which", {value: 75});
- Object.defineProperty(down, "ctrlKey", {value: true});
- var press = new KeyboardEvent("keypress", options);
- Object.defineProperty(press, "keyCode", {value: 75});
- Object.defineProperty(press, "which", {value: 75});
- Object.defineProperty(press, "ctrlKey", {value: true});
- document.querySelector('#app-mount').dispatchEvent(down);
- document.querySelector('#app-mount').dispatchEvent(press);
- }
- function checkForClosed(e) {
- var quickSwitcher = '.container-3uJcWB, .container-3uJcWB *',
- backdrop = document.querySelector('.backdrop-2ohBEd'),
- backdropQuickSwitcherCheck = document.querySelector('.backdrop-2ohBEd + .modal-2LIEKY .quickswitcher-2NdiGJ'),
- clickTarget = e.target;
- console.log('pie');
- if (clickTarget.matches(quickSwitcher)) {
- return;
- } else {
- if (backdropQuickSwitcherCheck) {
- globalSearchOuter.classList.remove('opened');
- document.removeEventListener('click', checkForClosed, false);
- backdrop.click();
- }
- }
- }
- if (quickSwitcherInput) {
- var quickParent = quickSwitcherInput.parentElement,
- quickSwitcherContainer = '.quickswitcher-2NdiGJ';
- if (quickParent.matches(quickSwitcherContainer)) {
- globalSearchInput.before(quickSwitcherInput);
- }
- document.removeEventListener('click', checkForClosed, false);
- } else {
- sendCtrlK();
- document.addEventListener('click', checkForClosed, false);
- }
- }
- globalSearchInput.addEventListener('focus', sendInput, false);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement