Skip to content

Instantly share code, notes, and snippets.

@kolyuchiy
Last active March 5, 2020 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kolyuchiy/772bfc4d1d9ac25eeca0b03a3f26e936 to your computer and use it in GitHub Desktop.
Save kolyuchiy/772bfc4d1d9ac25eeca0b03a3f26e936 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Open LOC in AppCode
// @namespace http://kolia.pp.ru/
// @version 0.1
// @description try to take over the world!
// @author nepolina@yandex-team.ru
// @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