Skip to content

Commit

Permalink
20230524 issues (#138)
Browse files Browse the repository at this point in the history
* fixes #131. caused by regex selecting minum of 4 digits for id, which has been changed to 2 digits.

* fixes #134. imdb videos now show both radarr and servarr icons

* update readme
  • Loading branch information
trossr32 authored May 24, 2023
1 parent 965144b commit 1bd7ffd
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 36 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Chrome Web Store](https://img.shields.io/chrome-web-store/v/jmmjjcddjldjdjgckdiokhfokccdnekc?label=Chrome%20web%20store&logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADdYAAA3WAZBveZwAAAIISURBVDhPdVLPaxNBFP52tyVpTGPbIImlLVEDtvVWwRZPooJUiLd6WBQFETTtRelV%2FAc8it6s6V0r%2BOsaBD14UwtCwEp%2FYNAejLvZNLuzM9M3s5tgC%2F3g7Xvvm%2Fn2vTczBv7D%2BrydI3eXrEQ2LqS0uJTf%2FZC%2Faof8yemll9tqn0JXSCKb3FOyjCb2gYR%2FPRbemnr2YkXlWkii6%2BQqnfwg%2BJxz12dzVHnFWHx9Lnd%2BdaB2aiu1p5KZOkS%2FkQDbiZkITcYaPCUneiie%2F3TSyZz4nUSSmbAOD6Ln6m186B2GCYlLuS2kt5cB7mmhlH0D3g67Z1J8pd0r8Lno6gXDLsP%2BYuJhdQMPqpuYe2%2BheeSGXlMwaBjLNEpKOK6Ib2MenGNZvPOHUG8GitJYd0K8%2FZWn3emYUWKjqIT6QAR9P056CATNtQ%2BME2eorV1Ila1FMfCD%2F8T0sItMwooZIJs0MTvSAEInZtScsmadtQtFimciCvjjfsXCzEXk00P0kzTuTDGMNpZhiuh0JRX3A76kruM45atkfXqFYFBb%2Bf4ChBSYtP7h8mA2XgECJloknDAflaqq1TJZdzhJgrqzhlZrExfoejrg9P4CxsuZ6cqGnpjEz8ndJGupvINZqpQwo0MJuXDbAb%2FWf6aiXtjeJ0Ztj5G7T1YaTSQKC0dHApqpFobiDbX4mCrV9UYAu%2FF1yscRLQLJAAAAAElFTkSuQmCC&style=plastic&color=brightgreen)](https://chrome.google.com/webstore/detail/sonarrradarrlidarr-autose/jmmjjcddjldjdjgckdiokhfokccdnekc) [![Chrome Web Store](https://img.shields.io/chrome-web-store/users/jmmjjcddjldjdjgckdiokhfokccdnekc?label=users&style=plastic&color=brightgreen)](https://chrome.google.com/webstore/detail/sonarrradarrlidarr-autose/jmmjjcddjldjdjgckdiokhfokccdnekc) [![Chrome Web Store](https://img.shields.io/chrome-web-store/stars/jmmjjcddjldjdjgckdiokhfokccdnekc?label=rating&style=plastic&color=brightgreen)](https://chrome.google.com/webstore/detail/sonarrradarrlidarr-autose/jmmjjcddjldjdjgckdiokhfokccdnekc)<br/>
[![Mozilla Add-on](https://img.shields.io/amo/v/sonarr-radarr-lidarr-search?label=Firefox%20add-ons&logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAA4AAAANCAYAAACZ3F9%2FAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAI6SURBVChTfVJNSFRRGD33vjdv3nvOmx9%2FygQRs5yoHAiMyGUGgdlGym2LNjW0SGhjtNB9hJvauAmiMGjTSmhTRBpWi1AzwkZTR0mdmeffzJt5z3e%2F7gyTtIgOXD74OOfcw%2BHD%2F0DZHo3syy%2FkvFBdHYBX579R8obg%2Bf3Y959Q%2BuLh6rYCVp2g0YYkQuoUlNYa1j%2F5jj6e0RE2NxAMWFAVQOAzhNbLWsfXy3y5kaJ7LZdA%2FnN46mm4wevx9Pjb9Iee%2B%2B5mpEvleRiRbJnaBJ8lhu7G2fDI%2FHTlR7od%2F4So04loEaglzKeu0tzUINPcIMzGBZzsG0XDsSVA04hMf4H5XjsXfefqsKN3ggWAozpwKIzjXa%2FZ%2BRuD2LJM5Ow2MIOAXQFkOIPH2mTkE6q3EWuW1QHSEORgtrYD418GUGQJWGEdoV1g%2Fv1Z1Hd%2Fg9i2wMIylTAaee5rW1bYIWDbABZrMDGZwFyGY5k2kVZtZCgPUcxBrMhEfBf0SwGtqzb3PXMlv1aXwo4Ubpm4wiZhFBaxl1mGbf%2BEcGaQCLwB3y6BF6RJyshShs1WyklHksna5rVHRmQP0D0UNAXTogUKJ3SYP6CXS4txeCIGErGh4MjYcEW4GhrgQnVeWQ25XiuaBw%2B4QMAHVPkUWYo8E6cYhqD6CfWI6NbHnpYODmA1dCfoM%2Fch052besjhWtAF5wL%2BvorSjkXMNZ9pFt2KLj2Wsf66nD%2BQBu2Sfg2MToEY56R8Z6S%2BbCo8mKlSJIDf81Pn%2Bw9CHy8AAAAASUVORK5CYII%3D&style=plastic&color=orange)](https://addons.mozilla.org/en-GB/firefox/addon/sonarr-radarr-lidarr-search/) [![Mozilla Add-on](https://img.shields.io/amo/users/sonarr-radarr-lidarr-search?label=users&style=plastic&color=orange)](https://addons.mozilla.org/en-GB/firefox/addon/sonarr-radarr-lidarr-search/) [![Mozilla Add-on](https://img.shields.io/amo/stars/sonarr-radarr-lidarr-search?label=rating&style=plastic&color=orange)](https://addons.mozilla.org/en-GB/firefox/addon/sonarr-radarr-lidarr-search/)<br />
[![](https://img.shields.io/static/v1?label=Edge%20add-ons&message=v2.7.0.0&color=blue&style=plastic&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJdSURBVDhPVVLPaxNBFP7eZJPNNomCqGj1aBGkB8WKF4/iyR4sQqGm4M1TKyoI1T+gf0BBqHhRoQW9CO1BEcUKIhSlh4rx18FKm1q7aZJustmdnZ3xTSj+ePDNDPPeN9+bb4bwT5x4vdqrocYN5HlNsg/oEFF7haj1Ku/UpxdPj77bKcUf4sBCbcQgnTZQRU0KGgk0xTDoIOf4KLjrxsvV77rZcHz+6G3ZJZ5aaFwCzEMDQ0xkApMsEZJ3IuRz6yjl11DIb8LNth45IhmmgQX/EGc/BVW/GPoNmFTB8TLwDvTA2eN2iT3uKnZ5qyh5m7wO4GSSYRF1grHvbz4Wq5VNBIGDUBbQambgL9fQrFS5n5ARMxQjhRAM0lfF2lJ10BajsA/G3c0owThF7mtvOdowZelvVY0OkWoJlWrECSGSOOmEbe8IuT3gC3GbGqZZg1x+e7P95PoMS2D/8wc61cGMUiFkItlNxaoqFqnIa50adKHY18oSiNy2JdnIFVbYwF+QqsFqATqyxYrtx8JofNV6h7i9BUpSUNYb2uFBYGNEoAqtfyKWPmP7hUyiG0w08wxO8GNEEZDJcs8Y3XXx3oglEtUvCKqfIbSH+J4DcaLOvjw+2ySa+HCQs5+FQEnELbjf3oOcPMieZtL7pPUdGL1EacIG6D4k0bnGs1tTwkz2rxtjrmi7nStCW6NY0orxdJnXizAm5sPtm1R4rtmksAMm+2dZoMwagTx8DNqkXM82/w1b12GUG08num7/98m57V4+cUyoaDDn/+jLhA0ScecLpWqOTDrVmLtmfwQH8BseJ1GMK7TIYwAAAABJRU5ErkJggg==)](https://microsoftedge.microsoft.com/addons/detail/sonarrradarrlidarr-auto/aclgfcjonnhgdkinhmmafdbkpegfcnal) ![Edge](https://img.shields.io/static/v1?label=users&message=388&color=blue&style=plastic)
[![](https://img.shields.io/static/v1?label=Edge%20add-ons&message=v2.7.1.0&color=blue&style=plastic&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJdSURBVDhPVVLPaxNBFP7eZJPNNomCqGj1aBGkB8WKF4/iyR4sQqGm4M1TKyoI1T+gf0BBqHhRoQW9CO1BEcUKIhSlh4rx18FKm1q7aZJustmdnZ3xTSj+ePDNDPPeN9+bb4bwT5x4vdqrocYN5HlNsg/oEFF7haj1Ku/UpxdPj77bKcUf4sBCbcQgnTZQRU0KGgk0xTDoIOf4KLjrxsvV77rZcHz+6G3ZJZ5aaFwCzEMDQ0xkApMsEZJ3IuRz6yjl11DIb8LNth45IhmmgQX/EGc/BVW/GPoNmFTB8TLwDvTA2eN2iT3uKnZ5qyh5m7wO4GSSYRF1grHvbz4Wq5VNBIGDUBbQambgL9fQrFS5n5ARMxQjhRAM0lfF2lJ10BajsA/G3c0owThF7mtvOdowZelvVY0OkWoJlWrECSGSOOmEbe8IuT3gC3GbGqZZg1x+e7P95PoMS2D/8wc61cGMUiFkItlNxaoqFqnIa50adKHY18oSiNy2JdnIFVbYwF+QqsFqATqyxYrtx8JofNV6h7i9BUpSUNYb2uFBYGNEoAqtfyKWPmP7hUyiG0w08wxO8GNEEZDJcs8Y3XXx3oglEtUvCKqfIbSH+J4DcaLOvjw+2ySa+HCQs5+FQEnELbjf3oOcPMieZtL7pPUdGL1EacIG6D4k0bnGs1tTwkz2rxtjrmi7nStCW6NY0orxdJnXizAm5sPtm1R4rtmksAMm+2dZoMwagTx8DNqkXM82/w1b12GUG08num7/98m57V4+cUyoaDDn/+jLhA0ScecLpWqOTDrVmLtmfwQH8BseJ1GMK7TIYwAAAABJRU5ErkJggg==)](https://microsoftedge.microsoft.com/addons/detail/sonarrradarrlidarr-auto/aclgfcjonnhgdkinhmmafdbkpegfcnal) ![Edge](https://img.shields.io/static/v1?label=users&message=441&color=blue&style=plastic)

## Overview

Expand All @@ -26,14 +26,18 @@ Leave a review:

[![Chrome Web Store](https://img.shields.io/chrome-web-store/v/jmmjjcddjldjdjgckdiokhfokccdnekc?label=Chrome%20web%20store&logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADdYAAA3WAZBveZwAAAIISURBVDhPdVLPaxNBFP52tyVpTGPbIImlLVEDtvVWwRZPooJUiLd6WBQFETTtRelV%2FAc8it6s6V0r%2BOsaBD14UwtCwEp%2FYNAejLvZNLuzM9M3s5tgC%2F3g7Xvvm%2Fn2vTczBv7D%2BrydI3eXrEQ2LqS0uJTf%2FZC%2Faof8yemll9tqn0JXSCKb3FOyjCb2gYR%2FPRbemnr2YkXlWkii6%2BQqnfwg%2BJxz12dzVHnFWHx9Lnd%2BdaB2aiu1p5KZOkS%2FkQDbiZkITcYaPCUneiie%2F3TSyZz4nUSSmbAOD6Ln6m186B2GCYlLuS2kt5cB7mmhlH0D3g67Z1J8pd0r8Lno6gXDLsP%2BYuJhdQMPqpuYe2%2BheeSGXlMwaBjLNEpKOK6Ib2MenGNZvPOHUG8GitJYd0K8%2FZWn3emYUWKjqIT6QAR9P056CATNtQ%2BME2eorV1Ila1FMfCD%2F8T0sItMwooZIJs0MTvSAEInZtScsmadtQtFimciCvjjfsXCzEXk00P0kzTuTDGMNpZhiuh0JRX3A76kruM45atkfXqFYFBb%2Bf4ChBSYtP7h8mA2XgECJloknDAflaqq1TJZdzhJgrqzhlZrExfoejrg9P4CxsuZ6cqGnpjEz8ndJGupvINZqpQwo0MJuXDbAb%2FWf6aiXtjeJ0Ztj5G7T1YaTSQKC0dHApqpFobiDbX4mCrV9UYAu%2FF1yscRLQLJAAAAAElFTkSuQmCC&style=plastic&color=brightgreen)](https://chrome.google.com/webstore/detail/sonarrradarrlidarr-autose/jmmjjcddjldjdjgckdiokhfokccdnekc)<br/>
[![Mozilla Add-on](https://img.shields.io/amo/v/sonarr-radarr-lidarr-search?label=Firefox%20add-ons&logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAA4AAAANCAYAAACZ3F9%2FAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAI6SURBVChTfVJNSFRRGD33vjdv3nvOmx9%2FygQRs5yoHAiMyGUGgdlGym2LNjW0SGhjtNB9hJvauAmiMGjTSmhTRBpWi1AzwkZTR0mdmeffzJt5z3e%2F7gyTtIgOXD74OOfcw%2BHD%2F0DZHo3syy%2FkvFBdHYBX579R8obg%2Bf3Y959Q%2BuLh6rYCVp2g0YYkQuoUlNYa1j%2F5jj6e0RE2NxAMWFAVQOAzhNbLWsfXy3y5kaJ7LZdA%2FnN46mm4wevx9Pjb9Iee%2B%2B5mpEvleRiRbJnaBJ8lhu7G2fDI%2FHTlR7od%2F4So04loEaglzKeu0tzUINPcIMzGBZzsG0XDsSVA04hMf4H5XjsXfefqsKN3ggWAozpwKIzjXa%2FZ%2BRuD2LJM5Ow2MIOAXQFkOIPH2mTkE6q3EWuW1QHSEORgtrYD418GUGQJWGEdoV1g%2Fv1Z1Hd%2Fg9i2wMIylTAaee5rW1bYIWDbABZrMDGZwFyGY5k2kVZtZCgPUcxBrMhEfBf0SwGtqzb3PXMlv1aXwo4Ubpm4wiZhFBaxl1mGbf%2BEcGaQCLwB3y6BF6RJyshShs1WyklHksna5rVHRmQP0D0UNAXTogUKJ3SYP6CXS4txeCIGErGh4MjYcEW4GhrgQnVeWQ25XiuaBw%2B4QMAHVPkUWYo8E6cYhqD6CfWI6NbHnpYODmA1dCfoM%2Fch052besjhWtAF5wL%2BvorSjkXMNZ9pFt2KLj2Wsf66nD%2BQBu2Sfg2MToEY56R8Z6S%2BbCo8mKlSJIDf81Pn%2Bw9CHy8AAAAASUVORK5CYII%3D&style=plastic&color=orange)](https://addons.mozilla.org/en-GB/firefox/addon/sonarr-radarr-lidarr-search/)<br />
[![](https://img.shields.io/static/v1?label=Edge%20add-ons&message=v2.7.0.0&color=blue&style=plastic&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJdSURBVDhPVVLPaxNBFP7eZJPNNomCqGj1aBGkB8WKF4/iyR4sQqGm4M1TKyoI1T+gf0BBqHhRoQW9CO1BEcUKIhSlh4rx18FKm1q7aZJustmdnZ3xTSj+ePDNDPPeN9+bb4bwT5x4vdqrocYN5HlNsg/oEFF7haj1Ku/UpxdPj77bKcUf4sBCbcQgnTZQRU0KGgk0xTDoIOf4KLjrxsvV77rZcHz+6G3ZJZ5aaFwCzEMDQ0xkApMsEZJ3IuRz6yjl11DIb8LNth45IhmmgQX/EGc/BVW/GPoNmFTB8TLwDvTA2eN2iT3uKnZ5qyh5m7wO4GSSYRF1grHvbz4Wq5VNBIGDUBbQambgL9fQrFS5n5ARMxQjhRAM0lfF2lJ10BajsA/G3c0owThF7mtvOdowZelvVY0OkWoJlWrECSGSOOmEbe8IuT3gC3GbGqZZg1x+e7P95PoMS2D/8wc61cGMUiFkItlNxaoqFqnIa50adKHY18oSiNy2JdnIFVbYwF+QqsFqATqyxYrtx8JofNV6h7i9BUpSUNYb2uFBYGNEoAqtfyKWPmP7hUyiG0w08wxO8GNEEZDJcs8Y3XXx3oglEtUvCKqfIbSH+J4DcaLOvjw+2ySa+HCQs5+FQEnELbjf3oOcPMieZtL7pPUdGL1EacIG6D4k0bnGs1tTwkz2rxtjrmi7nStCW6NY0orxdJnXizAm5sPtm1R4rtmksAMm+2dZoMwagTx8DNqkXM82/w1b12GUG08num7/98m57V4+cUyoaDDn/+jLhA0ScecLpWqOTDrVmLtmfwQH8BseJ1GMK7TIYwAAAABJRU5ErkJggg==)](https://microsoftedge.microsoft.com/addons/detail/sonarrradarrlidarr-auto/aclgfcjonnhgdkinhmmafdbkpegfcnal)
[![](https://img.shields.io/static/v1?label=Edge%20add-ons&message=v2.7.1.0&color=blue&style=plastic&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJdSURBVDhPVVLPaxNBFP7eZJPNNomCqGj1aBGkB8WKF4/iyR4sQqGm4M1TKyoI1T+gf0BBqHhRoQW9CO1BEcUKIhSlh4rx18FKm1q7aZJustmdnZ3xTSj+ePDNDPPeN9+bb4bwT5x4vdqrocYN5HlNsg/oEFF7haj1Ku/UpxdPj77bKcUf4sBCbcQgnTZQRU0KGgk0xTDoIOf4KLjrxsvV77rZcHz+6G3ZJZ5aaFwCzEMDQ0xkApMsEZJ3IuRz6yjl11DIb8LNth45IhmmgQX/EGc/BVW/GPoNmFTB8TLwDvTA2eN2iT3uKnZ5qyh5m7wO4GSSYRF1grHvbz4Wq5VNBIGDUBbQambgL9fQrFS5n5ARMxQjhRAM0lfF2lJ10BajsA/G3c0owThF7mtvOdowZelvVY0OkWoJlWrECSGSOOmEbe8IuT3gC3GbGqZZg1x+e7P95PoMS2D/8wc61cGMUiFkItlNxaoqFqnIa50adKHY18oSiNy2JdnIFVbYwF+QqsFqATqyxYrtx8JofNV6h7i9BUpSUNYb2uFBYGNEoAqtfyKWPmP7hUyiG0w08wxO8GNEEZDJcs8Y3XXx3oglEtUvCKqfIbSH+J4DcaLOvjw+2ySa+HCQs5+FQEnELbjf3oOcPMieZtL7pPUdGL1EacIG6D4k0bnGs1tTwkz2rxtjrmi7nStCW6NY0orxdJnXizAm5sPtm1R4rtmksAMm+2dZoMwagTx8DNqkXM82/w1b12GUG08num7/98m57V4+cUyoaDDn/+jLhA0ScecLpWqOTDrVmLtmfwQH8BseJ1GMK7TIYwAAAABJRU5ErkJggg==)](https://microsoftedge.microsoft.com/addons/detail/sonarrradarrlidarr-auto/aclgfcjonnhgdkinhmmafdbkpegfcnal)

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/K3K22CEIT)

All support is very gratefully received, thank you :raised_hands: :sunglasses: :+1:

## Change log (just the most recent; see [releases](https://github.com/trossr32/sonarr-radarr-lidarr-autosearch-browser-extension/releases) for full history)

**Bug fixes (V2.7.1)**
- Bug fix: TmdbId not parsed correctly from Trakt to Radarr search for some titles (<a href="https://github.com/trossr32/sonarr-radarr-lidarr-autosearch-browser-extension/issues/131">#131</a>)
- Bug fix: Icon not showing on IMDB (<a href="https://github.com/trossr32/sonarr-radarr-lidarr-autosearch-browser-extension/issues/134">#134</a>)

**New features (V2.7)**
- Readarr integration. Added as 2 separate configurations for ebooks and audiobooks. Works similarly to Lidarr, i.e. there are no site integrations so this only exposes new entries in the context menu.

Expand Down
88 changes: 60 additions & 28 deletions src/content/js/content_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{
siteId: 'sonarr',
match: {
pattern: /tv_show/i,
pattern: /(tv_show|other)/i,
operator: 'eq'
}
}
Expand Down Expand Up @@ -52,7 +52,7 @@
{
siteId: 'radarr',
match: {
pattern: /movie/i,
pattern: /(movie|other)/i,
operator: 'eq'
}
}
Expand Down Expand Up @@ -127,7 +127,7 @@
modifiers: [
{
type: 'regex-match',
pattern: /\/(?<search>\d{4,10})-/i
pattern: /\/(?<search>\d{2,10})-/i
}, {
type: 'prepend',
var: 'tmdb:'
Expand Down Expand Up @@ -226,7 +226,7 @@
modifiers: [
{
type: 'regex-match',
pattern: /\/(?<search>\d{4,10})/i
pattern: /\/(?<search>\d{2,10})/i
}, {
type: 'prepend',
var: 'tvdb:'
Expand Down Expand Up @@ -292,7 +292,7 @@
modifiers: [
{
type: 'regex-match',
pattern: /\/(?<search>\d{4,10})/i
pattern: /\/(?<search>\d{2,10})/i
}, {
type: 'prepend',
var: 'tmdb:'
Expand Down Expand Up @@ -731,7 +731,7 @@
imgStyles: 'width: 30px; margin: 7px 0 0 0;'
}
},
// myanimelist sonarr
// myanimelist sonarr
{
id: 'myanimelist',
defaultSite: 'sonarr',
Expand Down Expand Up @@ -792,7 +792,7 @@
// modifiers: [
// {
// type: 'regex-match',
// pattern: /\/(?<search>\d{4,10})/i
// pattern: /\/(?<search>\d{2,10})/i
// }, {
// type: 'prepend',
// var: 'tmdb:'
Expand Down Expand Up @@ -938,21 +938,20 @@ var title = (s, removeUnderscore) => {
};

/**
* Get HTML markup for a custom icon to inject into the body.
* Add a custom icon and inject into the body.
* @param {InjectedIconConfig} injectedIconConfig - injected icon config
* @param {string} iconDataUri - icon data uri
* @param {string} siteId - id of the servarr site; sonarr, radarr, lidarr, etc.
* @returns {string} - HTML to inject
*/
function getCustomIconMarkup(injectedIconConfig, siteId, linkHref) {
return `<style id="servarr-ext_custom-icon-style">
function addCustomIconMarkup(injectedIconConfig, siteId, linkHref) {
let styles = `<style id="servarr-ext_custom-icon-style">
.servarr-ext_icon a {
position: absolute;
background-color: ${injectedIconConfig.backgroundColor};
text-decoration: none;
height: 52px;
z-index: 9999999;
${injectedIconConfig.position}: ${injectedIconConfig.positionOffset};
}
.servarr-ext_anchored-icon a {
Expand All @@ -962,7 +961,6 @@ return `<style id="servarr-ext_custom-icon-style">
.servarr-ext_floating-icon a {
width: 52px;
${injectedIconConfig.side}: ${injectedIconConfig.sideOffset};
border-radius: 50px;
}
Expand All @@ -987,33 +985,69 @@ return `<style id="servarr-ext_custom-icon-style">
.servarr-ext_icon-image {
width: 40px;
height: 40px;
background: url('${base64Icons_40px.find(i => i.id == siteId).base64}') no-repeat;
}
.servarr-ext_anchored-icon .servarr-ext_icon-image {
top: 6px;
}
.servarr-ext_floating-icon .servarr-ext_icon-image {
margin: ${(siteId == 'radarr' ? '6px 0px 0px 8px' : '6px 0px 0px 6px')};
}
.servarr-ext_anchored-left-icon .servarr-ext_icon-image {
float: right;
margin: ${(siteId == 'radarr' ? '6px -10px 0 0' : '6px -10px 0 0')};
}
.servarr-ext_anchored-right-icon .servarr-ext_icon-image {
float: left;
margin: ${(siteId == 'radarr' ? '6px 0px 0px -5px' : '6px 0px 0px -9px')};
}
</style>
<div id="servarr-ext_custom-icon-wrapper" class="servarr-ext_icon servarr-ext_${injectedIconConfig.type}-icon ${(injectedIconConfig.type == 'anchored' ? ('servarr-ext_anchored-' + injectedIconConfig.side + '-icon') : '')}">
<a href="${linkHref}" target="_blank" data-servarr-icon="true">
<div class="servarr-ext_icon-image"></div>
<!-- ${(injectedIconConfig.type == 'anchored' ? ('<div class="servarr-ext_anchor-label">Search<br />' + title(siteId, true) + '</div>') : '')} -->
</a>
</style>`;

let siteStyles = `.servarr-ext_icon-image-${siteId} {
background: url('${base64Icons_40px.find(i => i.id == siteId).base64}') no-repeat;
}
.servarr-ext_floating-icon .servarr-ext_icon-image-${siteId} {
margin: ${(siteId == 'radarr' ? '6px 0px 0px 8px' : '6px 0px 0px 6px')};
}
.servarr-ext_anchored-left-icon .servarr-ext_icon-image-${siteId} {
margin: ${(siteId == 'radarr' ? '6px -10px 0 0' : '6px -10px 0 0')};
}
.servarr-ext_anchored-right-icon .servarr-ext_icon-image-${siteId} {
margin: ${(siteId == 'radarr' ? '6px 0px 0px -5px' : '6px 0px 0px -9px')};
}`;

// anchor tag
let anchor = `<a href="${linkHref}" target="_blank" data-servarr-icon="true" class="servarr-ext_anchor-${siteId} servarr-ext_${injectedIconConfig.type}-anchor-${siteId}">
<div class="servarr-ext_icon-image servarr-ext_icon-image-${siteId}"></div>
<!-- ${(injectedIconConfig.type == 'anchored' ? ('<div class="servarr-ext_anchor-label">Search<br />' + title(siteId, true) + '</div>') : '')} -->
</a>`;

// check if the wrapper already exists
if ($('#servarr-ext_custom-icon-wrapper').length) {
log(['found servarr-ext_custom-icon-wrapper']);

let positionOffset = injectedIconConfig.type == 'anchored' ? `calc(${injectedIconConfig.positionOffset} ${(injectedIconConfig.position === 'top' ? '+' : '-')} 57px)` : injectedIconConfig.positionOffset;
let sideOffset = injectedIconConfig.type == 'anchored' ? injectedIconConfig.sideOffset : `calc(${injectedIconConfig.sideOffset} ${(injectedIconConfig.position === 'left' ? '+' : '-')} 57px)`;

siteStyles += `.servarr-ext_anchor-${siteId} { ${injectedIconConfig.position}: ${positionOffset}; }
.servarr-ext_floating-anchor-${siteId} { ${injectedIconConfig.side}: ${sideOffset}; }`;

$('body').prepend(`<style id="servarr-ext_custom-icon-style-${siteId}">${siteStyles}</style>`);

$('#servarr-ext_custom-icon-wrapper').append(anchor);

return;
}

// anchor doesn't exist, create the wrapper
let wrapper = `<div id="servarr-ext_custom-icon-wrapper" class="servarr-ext_icon servarr-ext_${injectedIconConfig.type}-icon ${(injectedIconConfig.type == 'anchored' ? ('servarr-ext_anchored-' + injectedIconConfig.side + '-icon') : '')}">
${anchor}
</div>`;

siteStyles += `.servarr-ext_anchor-${siteId} { ${injectedIconConfig.position}: ${injectedIconConfig.positionOffset}; }
.servarr-ext_floating-anchor-${siteId} { ${injectedIconConfig.side}: ${injectedIconConfig.sideOffset}; }`;

$('body').prepend(`${styles}<style id="servarr-ext_custom-icon-style-${siteId}">${siteStyles}</style>${wrapper}`);
}

async function init() {
Expand Down Expand Up @@ -1203,9 +1237,7 @@ async function init() {
}
} else {
// show a custom icon based on the icon config
let el = getCustomIconMarkup(settings.injectedIconConfig, site.id, searchUrl);

$('body').prepend(el);
addCustomIconMarkup(settings.injectedIconConfig, site.id, searchUrl);
}

containerEl.attr('data-servarr-ext-completed', true);
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Sonarr/Radarr/Lidarr autosearch",
"description": "Exposes a context menu that enables direct searching for tv shows, movies and other text in Sonarr, Radarr, Lidarr and Readarr.",
"version": "2.7.0.0",
"version": "2.7.1.0",
"browser_action": {
"default_icon": "content/assets/images/SonarrRadarrLidarr128.png",
"default_popup": "popup.html"
Expand Down
Loading

0 comments on commit 1bd7ffd

Please sign in to comment.