viewvc-link-log-view

Provides links to log view for directories in ViewVC until http://viewvc.tigris.org/issues/show_bug.cgi?id=470 is implemented

  1. // ==UserScript==
  2. // @name viewvc-link-log-view
  3. // @version 0.1
  4. // @description Provides links to log view for directories in ViewVC until http://viewvc.tigris.org/issues/show_bug.cgi?id=470 is implemented
  5. // @author Keegan Witt
  6. // @include http://svn.*/viewvc/*
  7. // @namespace https://greasyfork.org/users/9482
  8. // ==/UserScript==
  9.  
  10. // a function that loads jQuery and calls a callback function when jQuery has finished loading
  11. function addJQuery(callback) {
  12. var script = document.createElement("script");
  13. script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js");
  14. script.addEventListener('load', function() {
  15. var script = document.createElement("script");
  16. script.textContent = "(" + callback.toString() + ")();";
  17. document.body.appendChild(script);
  18. }, false);
  19. document.body.appendChild(script);
  20. }
  21.  
  22. // the guts of this userscript
  23. function main() {
  24. var loc = "" + document.location.href;
  25. var view = new RegExp(/.+view=/);
  26. if (!loc.match(view)) {
  27. // $("h1").after("<a href=\"" + encodeURI(document.location.href + "?view=log") + "\"><img src=\"/viewvc/*docroot*/images/log.png\" height=\"16\" width=\"16\"> Log" + "</a>");
  28. $("h1").after("<a href=\"" + encodeURI(document.location.href + "?view=log") + "\">Log" + "</a>" + "<br/>");
  29. }
  30. }
  31.  
  32. // load jQuery and execute the main function
  33. addJQuery(main);