Letterboxd Button for KinoPub

Add a styled "Log on Letterboxd" button to movie pages on kino.pub

  1. // Добавьте свои зеркала в раздел match
  2. // ==UserScript==
  3. // @name Letterboxd Button for KinoPub
  4. // @name:ru Кнопка Letterboxd для Кинопаб
  5. // @version 1.3
  6. // @description Add a styled "Log on Letterboxd" button to movie pages on kino.pub
  7. // @description:ru Добавляет кнопку страницы фильма на Letterboxd под плеером Кинопаба
  8. // @author Lex Fradski
  9. // @match https://*.btr.ovh/item/view/*
  10. // @match https://kino.pub/item/view/*
  11. // @grant none
  12. // @namespace https://greasyfork.org/users/1231710
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. // Wait for the DOM to load
  19. window.addEventListener('load', function() {
  20. let imdbLink = document.querySelector('a[href*="imdb.com/title/"]');
  21. if (imdbLink) {
  22. // Extract only the numeric part of the IMDb ID
  23. let imdbIdMatch = imdbLink.href.match(/tt(\d+)/);
  24. let imdbId = imdbIdMatch ? imdbIdMatch[1] : null;
  25. if (imdbId) {
  26. let letterboxdUrl = `https://letterboxd.com/imdb/${imdbId}`;
  27. let seenButton = document.getElementById('movie-status');
  28.  
  29. if (seenButton) {
  30. let letterboxdButton = document.createElement('button');
  31. letterboxdButton.innerHTML = '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" style="height: 14px; width: 14px; vertical-align: text-bottom; fill: currentColor;"><path d="M8.224 14.352a4.447 4.447 0 0 1-3.775 2.092C1.992 16.444 0 14.454 0 12s1.992-4.444 4.45-4.444c1.592 0 2.988.836 3.774 2.092-.427.682-.673 1.488-.673 2.352s.246 1.67.673 2.352zM15.101 12c0-.864.247-1.67.674-2.352-.786-1.256-2.183-2.092-3.775-2.092s-2.989.836-3.775 2.092c.427.682.674 1.488.674 2.352s-.247 1.67-.674 2.352c.786 1.256 2.183 2.092 3.775 2.092s2.989-.836 3.775-2.092A4.42 4.42 0 0 1 15.1 12zm4.45-4.444a4.447 4.447 0 0 0-3.775 2.092c.427.682.673 1.488.673 2.352s-.246 1.67-.673 2.352a4.447 4.447 0 0 0 3.775 2.092C22.008 16.444 24 14.454 24 12s-1.992-4.444-4.45-4.444z"/></svg> Открыть на Letterboxd';
  32. letterboxdButton.className = seenButton.className; // Copy the class of "Уже видел" button
  33. letterboxdButton.style.marginLeft = '10px';
  34. letterboxdButton.onclick = function() {
  35. window.open(letterboxdUrl, '_blank');
  36. };
  37.  
  38. seenButton.parentNode.insertBefore(letterboxdButton, seenButton.nextSibling);
  39. }
  40. }
  41. }
  42. });
  43. })();