// ==UserScript== // @name github.com raw diff link // @namespace github.com // @description Appends raw diff link // @include https://github.com/*/*/commit/* // ==/UserScript== var file = document.getElementsByClassName('file')[0], code = file.getElementsByTagName('code')[0], li = code.parentNode.parentNode, loc = window.location + '', rawlink = document.createElement('a') ; if(window.location.hash != ''){ loc = loc.replace(window.location.hash,''); } rawlink.setAttribute('hotkey', 'r'); rawlink.appendChild(document.createTextNode('view diff')); rawlink.setAttribute('href',loc + '.diff'); rawlink.setAttribute('style','margin-left:1em;'); li.appendChild(rawlink);