Advertisement
Guest User

Untitled

a guest
Oct 4th, 2023
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. // ==UserScript==
  2. // @name iNaturalist Geomodel Viewier
  3. // @version 1.0
  4. // @description Add a link to the Geomodel result for iNaturalist taxa
  5. // @author Nathan Ruser
  6. // @match https://www.inaturalist.org/taxa/*
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. 'use strict';
  12.  
  13. // Get the Taxa ID from the URL
  14. const match = window.location.pathname.match(/\/taxa\/(\d+)/);
  15. if (!match) return; // Exit if not on a valid taxa page
  16. const taxaId = match[1];
  17.  
  18. // Create a link element
  19. const link = document.createElement('a');
  20. link.href = `https://www.inaturalist.org/geo_model/${taxaId}/explain`;
  21. link.textContent = 'Geo-Model';
  22.  
  23. // Apply CSS styles
  24. link.style.border = '0 transparent';
  25. link.style.backgroundColor = 'inherit';
  26. link.style.color = 'black';
  27. link.style.opacity = '1';
  28. link.style.textDecoration = 'none'; // Remove underline
  29. link.addEventListener('mouseenter', () => {
  30. link.style.borderBottom = '3px solid #74ac00';
  31. });
  32. link.addEventListener('mouseleave', () => {
  33. link.style.borderBottom = 'none';
  34. });
  35.  
  36. // Find the "Map" tab
  37. const mapTab = document.querySelector('a[href="#map-tab"]');
  38. if (mapTab) {
  39. // Create a new list item for the link
  40. const listItem = document.createElement('li');
  41. listItem.appendChild(link);
  42.  
  43. // Insert the list item after the "Map" tab
  44. mapTab.parentElement.insertAdjacentElement('afterend', listItem);
  45. }
  46. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement