Greasy Fork is available in English.

Github.io show source

Go to source code of a github.io page. Source code on https://github.com/LuisMayo/general-userscripts/

  1. // ==UserScript==
  2. // @name Github.io show source
  3. // @namespace LuisMayo
  4. // @version 0.1
  5. // @description Go to source code of a github.io page. Source code on https://github.com/LuisMayo/general-userscripts/
  6. // @author LuisMayo
  7. // @match https://*.github.io/*
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. 'use strict';
  12. const container = document.createElement('a');
  13. container.style.position = 'absolute';
  14. container.style.right = '20px';
  15. container.style.top = '20px';
  16. container.style.zIndex = '1';
  17. container.style.backgroundColor = 'black';
  18. container.style.cursor = 'pointer';
  19. const goToGithubButton = document.createElement('span');
  20. goToGithubButton.style.border = '2px solid antiquewhite';
  21. goToGithubButton.style.backgroundColor = 'antiquewhite';
  22. goToGithubButton.style.borderRightColor = 'cornsilk';
  23. goToGithubButton.textContent = 'Open Source Code on github';
  24. goToGithubButton.addEventListener('click', (ev) => {
  25. const root = "https://github.com"
  26. const accountName = location.hostname.substring(0, location.hostname.indexOf('.'));
  27. const projectName = location.pathname.length > 1 ? location.pathname : location.hostname;
  28. window.open(root + '/' + accountName + '/' + projectName);
  29. });
  30. container.appendChild(goToGithubButton);
  31. const dismissLink = document.createElement('a');
  32. dismissLink.style.border = '2px solid antiquewhite';
  33. dismissLink.style.backgroundColor = 'antiquewhite';
  34. dismissLink.textContent = 'Dismiss';
  35. dismissLink.addEventListener('click', (ev) => container.remove());
  36. container.appendChild(dismissLink);
  37. document.body.appendChild(container);
  38. })();