Greasy Fork is available in English.

Hide github fork button

Hide github fork button for some reason.

Fra 12.04.2016. Se den seneste versjonen.

  1. // ==UserScript==
  2. // @name Hide github fork button
  3. // @namespace https://github.com/mozillazg/hide-github-fork-button.user.js
  4. // @description Hide github fork button for some reason.
  5. // @version 0.1.0
  6. // @author mozillazg
  7. // @include https://github.com/test/*
  8. // @run-at document-end
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. "use strict";
  13.  
  14. function isContainFork() {
  15. return (document.querySelectorAll("#fork-destination-box").length !== 0);
  16. }
  17.  
  18. function hideFork() {
  19. var buttons = document.querySelectorAll(".experiment-repo-nav .pagehead-actions li");
  20. if (buttons.length > 2) {
  21. var forkButton = buttons[2];
  22. forkButton.remove();
  23. }
  24. }
  25.  
  26. // run
  27. function run() {
  28. if (isContainFork()) {
  29. hideFork();
  30. }
  31. }
  32.  
  33. // DOM targets - to detect GitHub dynamic ajax page loading
  34. var targets = document.querySelectorAll([
  35. "#js-repo-pjax-container",
  36. "#js-pjax-container"
  37. ].join(","));
  38.  
  39. Array.prototype.forEach.call(targets, function(target) {
  40. // detect DOM change
  41. new MutationObserver(function(mutations) {
  42. mutations.forEach(function(mutation) {
  43. run();
  44. });
  45. }).observe(target, {
  46. childList: true,
  47. subtree: true
  48. });
  49. });
  50.  
  51. run();
  52. })();