instagram_to_bibliogram.user.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // ==UserScript==
  2. // @name Instagram to Bibliogram
  3. // @author Jesús E.
  4. // @namespace BibliogramRedirect
  5. // @description Scan page for Instagram and urls replace with Bibliogram
  6. // @homepageURL https://git.sr.ht/~heckyel/book/blob/master/scripts-greasemonkey
  7. // @include *
  8. // @exclude /^http(s|)://(www[.]|)bibliogram[.]art/.*$/
  9. // @exclude /^http(s|)://(www[.]|)bibliogram[.]snopyta[.]org/.*$/
  10. // @exclude /^http(s|)://(www[.]|)bibliogram[.]pussthecat[.]org/.*$/
  11. // @version 0.1.6
  12. // @grant none
  13. // @license GPL version 3 or any later version::: https://www.gnu.org/licenses/gpl-3.0.html
  14. // ==/UserScript==
  15. /* jshint esversion: 6 */
  16. // Set you favorite Bibliogram instance! (https://github.com/cloudrac3r/bibliogram/wiki/Instances#instance-list)
  17. let instance = 'bibliogram.snopyta.org';
  18. // Console Style - Debug
  19. const consoleCSS = 'background: #000; color: #00FF00; padding: 0px 7px; border: 1px solid #00FF00; line-height: 16px;';
  20. const name = GM_info.script.name;
  21. const version = GM_info.script.version;
  22. const log = (...args) => console.log('%cUSERSCRIPT | %s %s | %s', consoleCSS, name, version, ...args);
  23. // Do the actual rewrite
  24. function rewriteLinks() {
  25. for (let i = 0; i < document.links.length; i++) {
  26. let elem = document.links[i];
  27. if (elem.href.match(/http(s|):\/\/(mobile[.]|www[.]|)instagram[.]com\/(#!\/)?(.*$)/i)) {
  28. elem.href='https://' + instance + '/u/' + RegExp.$4;
  29. }
  30. }
  31. log('successfully initialized');
  32. }
  33. window.addEventListener('load', () => {
  34. rewriteLinks();
  35. });