Last active
March 5, 2020 10:27
-
-
Save kolyuchiy/772bfc4d1d9ac25eeca0b03a3f26e936 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Open LOC in AppCode | |
// @namespace http://kolia.pp.ru/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author [email protected] | |
// @match https://github.yandex-team.ru/taxi/mobile-taxi-client-ios/pull/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function addListeners(rootEl) { | |
let files = rootEl.getElementsByClassName('file'); | |
for (let file of files) { | |
let fileHeader = file.getElementsByClassName('file-header').item(0); | |
let fileName = fileHeader.innerText; | |
let lineNumbers = file.getElementsByClassName('js-linkable-line-number'); | |
for (let el of lineNumbers) { | |
let line = el.getAttribute('data-line-number'); | |
if (typeof el.xxx_addedLOCListener !== 'undefined') { | |
continue; | |
} | |
el.xxx_addedLOCListener = true | |
el.addEventListener('click', function () { | |
console.log(line, fileName); | |
window.location = 'hammerspoon://open-line?line=' + line + '&file=' + fileName; | |
}); | |
} | |
} | |
} | |
addListeners(document); | |
var observer = new MutationObserver(function(mutations) { | |
addListeners(document); | |
}); | |
observer.observe(document, { childList: true, subtree: true }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment