Fbox (formally Fmovies) Movie/TV Show IMDb Linker

Automatically converts movie and TV show titles on fmoviesz.to into clickable IMDb links.

  1. // ==UserScript==
  2. // @name Fbox (formally Fmovies) Movie/TV Show IMDb Linker
  3. // @namespace https://gf.qytechs.cn/en/users/158563-flowscript
  4. // @version 2.5
  5. // @description Automatically converts movie and TV show titles on fmoviesz.to into clickable IMDb links.
  6. // @author flowscript
  7. // @license MIT
  8. // @match https://fboxz.to/*
  9. // @icon https://fboxz.to/assets/s/efc53769e615dedbfa14097647c484fc1b53872ef2.png
  10. // @grant GM_xmlhttpRequest
  11. // @grant GM_openInTab
  12. // @grant GM_setValue
  13. // @grant GM_getValue
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. let apiKey = GM_getValue('apiKey', '');
  20.  
  21. function createApiKeyBar() {
  22. const bar = document.createElement('div');
  23. bar.id = 'api-key-bar';
  24. bar.style.position = 'fixed';
  25. bar.style.top = '0';
  26. bar.style.left = '0';
  27. bar.style.right = '0';
  28. bar.style.background = 'white';
  29. bar.style.zIndex = '9999';
  30. bar.style.display = 'flex';
  31. bar.style.justifyContent = 'space-around';
  32. bar.style.alignItems = 'center';
  33. bar.style.padding = '10px';
  34. bar.innerHTML = `
  35. <div style="max-width: 650px; width: 100%; display: flex; justify-content: space-between; align-items: center;">
  36. <span style="color:#000">Enter your OMDb API key:</span>
  37. <input type="text" id="api-key-input" value="${apiKey}" placeholder="Your OMDb API Key" />
  38. <button id="save-api-key">Save</button>
  39. <a style="color:#000; text-decoration: underline;" href="https://www.omdbapi.com/apikey.aspx?__EVENTTARGET=freeAcct&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=%2FwEPDwUKLTIwNDY4MTIzNWQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgMFC3BhdHJlb25BY2N0BQhmcmVlQWNjdAUIZnJlZUFjY3TPFbhDNAP5k2IyKPJ7m9uxWYueZItroF14oycQCjz74g%3D%3D&__VIEWSTATEGENERATOR=5E550F58&__EVENTVALIDATION=%2FwEdAAqlA4T7vBlT9mLCvJHK4jtLmSzhXfnlWWVdWIamVouVTzfZJuQDpLVS6HZFWq5fYpioiDjxFjSdCQfbG0SWduXFd8BcWGH1ot0k0SO7CfuulF0vVes0SOcL8qM3Jr6aqHyFE%2Bczl1aCyjbLtuPuRU0tIVu1gi3bgvDqS3Gt3lnrv%2FgsVJPMV9tdMU3lWBBf01vN%2BDvxnwFeFeJ9MIBWR693lV1nVMd%2BBdOykS6U5QG9tWPPrmmNyoXzpQ6YDVjG%2F3M%3D&at=freeAcct&Email=&Email2=&FirstName=&LastName=&TextArea1=" target="_blank">Get an API Key</a>
  40. <button id="close-api-key-bar" style="margin-left: 20px;">X</button>
  41. </div>
  42. `;
  43. document.body.appendChild(bar);
  44.  
  45. document.getElementById('save-api-key').addEventListener('click', function() {
  46. apiKey = document.getElementById('api-key-input').value.trim();
  47. GM_setValue('apiKey', apiKey);
  48. hideApiKeyBar();
  49. createApiKeySettingsButton(); // Ensure the button is available for future changes
  50. window.location.reload(); // Reload the page after saving the API key
  51. });
  52.  
  53. // Close button functionality
  54. document.getElementById('close-api-key-bar').addEventListener('click', function() {
  55. hideApiKeyBar();
  56. });
  57. }
  58.  
  59. function createApiKeySettingsButton() {
  60. let button = document.getElementById('api-key-settings-button');
  61. if (!button) {
  62. button = document.createElement('button');
  63. button.id = 'api-key-settings-button';
  64. button.textContent = 'API Key Settings';
  65. button.style.position = 'fixed';
  66. button.style.top = '0';
  67. button.style.right = '0';
  68. button.style.zIndex = '9998';
  69. document.body.appendChild(button);
  70.  
  71. button.addEventListener('click', function() {
  72. let bar = document.getElementById('api-key-bar');
  73. if (!bar) {
  74. createApiKeyBar(); // Recreate the API key bar if it doesn't exist
  75. bar = document.getElementById('api-key-bar'); // Re-assign 'bar' after creation
  76. }
  77. bar.style.display = 'flex'; // Ensure the bar is visible
  78. });
  79. }
  80. }
  81.  
  82. function hideApiKeyBar() {
  83. const bar = document.getElementById('api-key-bar');
  84. bar.style.display = 'none';
  85. }
  86.  
  87. if (!apiKey) {
  88. createApiKeyBar();
  89. } else {
  90. createApiKeySettingsButton();
  91. }
  92.  
  93. // Begin IMDb Linker Script
  94. // Modified fetchIMDbID function with year adjustment logic
  95. function fetchIMDbID(title, year, type, callback, attempt = 0) {
  96. if (!apiKey) {
  97. alert("OMDb API key is not set. Please set your API key at the top of the page.");
  98. return;
  99. }
  100.  
  101. const apiType = type === 'TV' ? 'series' : 'movie';
  102. const apiUrl = `https://www.omdbapi.com/?apikey=${apiKey}&type=${apiType}&t=${encodeURIComponent(title)}&y=${year}`;
  103.  
  104. console.log(`Fetching IMDb ID for: ${title} ${year} ${type}`);
  105.  
  106. GM_xmlhttpRequest({
  107. method: 'GET',
  108. url: apiUrl,
  109. onload: (response) => {
  110. const data = JSON.parse(response.responseText);
  111. if (data.Response === 'True') {
  112. console.log(`Found: ${title} ${year}`);
  113. callback(data.imdbID);
  114. } else {
  115. if (attempt === 0) {
  116. console.log(`Failed to find IMDb ID: ${title}, checking previous year for: ${title} ${year-1}`);
  117. fetchIMDbID(title, year-1, type, callback, -1); // Check previous year
  118. } else if (attempt === -1) {
  119. console.log(`Failed to find IMDb ID: ${title}, checking next year for: ${title} ${parseInt(year)+2}`);
  120. fetchIMDbID(title, parseInt(year)+2, type, callback, 1); // Skip to next year after original
  121. } else {
  122. console.error(`Failed to find IMDb ID after checks: ${title}`);
  123. callback(null);
  124. }
  125. }
  126. }
  127. });
  128. }
  129.  
  130. const titleElement = document.querySelector('h1.name');
  131. const yearElement = document.querySelector('.year');
  132. const path = window.location.pathname;
  133.  
  134. const title = titleElement ? titleElement.innerText.trim() : '';
  135. const year = yearElement ? parseInt(yearElement.innerText.trim(), 10) : '';
  136. const type = path.includes('/tv/') ? 'TV' : 'Movie';
  137.  
  138. if (title && year && type) {
  139. fetchIMDbID(title, year, type, (imdbID) => {
  140. if (imdbID) {
  141. const imdbLink = document.createElement('a');
  142. imdbLink.href = `https://www.imdb.com/title/${imdbID}/`;
  143. imdbLink.target = '_blank';
  144. imdbLink.innerHTML = title; // Wrap the original title text
  145. titleElement.innerHTML = ''; // Clear existing content
  146. titleElement.appendChild(imdbLink); // Insert the link
  147. }
  148. });
  149. }
  150. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址