Created
June 23, 2011 00:55
-
-
Save 958/1041661 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
--- a/104764.user.js | |
+++ b/104764.user.js | |
@@ -11,15 +11,15 @@ | |
// raw URL rule | |
// http://wa.cocolog-enshu.com/pseudodiary/2011/06/gist-raw-url-72.html | |
(function() { | |
- var codes = document.querySelectorAll('.code > a'); | |
- if (!codes) { | |
+ var files = document.querySelectorAll('.file'); | |
+ if (!files) { | |
return; | |
} | |
var pathname = getGistPathname(); | |
- for (var i = 0,len = codes.length; i < len; i++) { | |
- var code = codes[i]; | |
- // code.hrefは絶対URLが取得されるため | |
- var codeFilename = code.getAttribute("href").replace("#file_", ""); | |
+ for (var i = 0,len = files.length; i < len; i++) { | |
+ var file = files[i]; | |
+ var code = file.querySelector('.code > a'); | |
+ var codeFilename = file.querySelector('.actions>a:last-child').getAttribute('href').split('/').pop(); | |
var rawLink = document.createElement("a"); | |
var rawURL = "https://raw.github.com/gist/" + pathname + "/" + codeFilename; | |
rawLink.href = rawURL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment