Funimation AP Features

Search on AP and opening full size cover

  1. // ==UserScript==
  2. // @name Funimation AP Features
  3. // @namespace https://greasyfork.org/en/users/689482-quin15
  4. // @version 1.0.2
  5. // @description Search on AP and opening full size cover
  6. // @author Quin15
  7. // @match https://www.funimation.com/shows/*
  8. // @icon https://www.google.com/s2/favicons?domain=funimation.com
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. var checkElems = function() {if ((document.querySelector('a[data-test="content-hero__watch-cta"]') || document.querySelector('button[data-test="content-hero__watch-cta"]')) && document.querySelector('div[role="img"] div[class^="v-image__image"]').style.backgroundImage) {setTimeout(addButtons, 200)} else {setTimeout(checkElems, 200);}};
  13. checkElems();
  14.  
  15. var addButtons = function() {
  16. var searchAP = document.createElement('a');
  17. searchAP.setAttribute('data-v-06672a12', '')
  18. searchAP.className = 'px-5 v-btn v-btn--has-bg v-btn--router theme--dark v-size--large secondary';
  19. searchAP.style.minWidth = "212px";
  20. searchAP.innerHTML = `<img src="https://www.anime-planet.com/favicon.ico" style="float:left;height:40px;"><span class="v-btn__content"><div data-v-06672a12="" style="margin-left:10px;"> Search On AP </div></span>`;
  21. document.querySelector('div[class="v-card__actions order-1 order-md-5 px-0 pb-md-0"]').appendChild(searchAP);
  22. searchAP.addEventListener("click", function() {open(encodeURI("https://www.anime-planet.com/anime/all?name=" + document.querySelector('h1[data-test="content-hero__title"]').innerText), "")});
  23.  
  24. var coverImg = document.createElement('a');
  25. coverImg.setAttribute('data-v-06672a12', '')
  26. coverImg.className = 'px-5 v-btn v-btn--has-bg v-btn--router theme--dark v-size--large secondary';
  27. coverImg.style.minWidth = "212px";
  28. coverImg.innerHTML = `<img src="` + document.querySelector('div[role="img"] div[class^="v-image__image"]').style.backgroundImage.replace(/.*url\(\"/, '').replace('")', '') + `" style="float:left;height:40px;"><span class="v-btn__content"><div data-v-06672a12="" style="margin-left:10px;"> Open Cover Image </div></span>`;
  29. document.querySelector('div[class="v-card__actions order-1 order-md-5 px-0 pb-md-0"]').appendChild(coverImg);
  30. coverImg.addEventListener("click", function() {open(document.querySelector('div[role="img"] div[class^="v-image__image"]').style.backgroundImage.replace(/.*url\(\"/, '').replace('")', '').replace(/upload\/.*\,c\_fill/, 'upload/c_fill'), "")});
  31. }