SHARE
TWEET

Untitled

a guest Aug 14th, 2019 333 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Amazon Video ASIN Display
  3. // @namespace    nyuszika7h@gmail.com
  4. // @version      0.2.1
  5. // @description  Show ASINs for episodes and movies/seasons on Amazon Prime Video
  6. // @author       nyuszika7h
  7. // @match        https://www.amazon.com/*
  8. // @match        https://www.amazon.co.uk/*
  9. // @match        https://www.amazon.de/*
  10. // @match        https://www.amazon.co.jp/*
  11. // @match        https://www.primevideo.com/*
  12. // @grant        none
  13. // ==/UserScript==
  14.  
  15. (function() {
  16.   'use strict';
  17.  
  18.   let style = document.createElement('style');
  19.   let styleText = document.createTextNode(`
  20. .x-episode-asin {
  21.   margin: 0.5em 0;
  22.   color: #ff0000;
  23. }
  24.  
  25. .x-page-asin {
  26.   margin: 0.5em 0 1em 0;
  27.   color: #ff0000;
  28. }`);
  29.   style.appendChild(styleText);
  30.   document.head.appendChild(style);
  31.  
  32.   // Amazon old style
  33.   document.querySelectorAll('.dv-episode-container').forEach(el => {
  34.     let asins = el.dataset.aliases.replace(/,/g, ' / ');
  35.  
  36.     let asinEl = document.createElement('div');
  37.     let text = document.createTextNode(asins);
  38.     asinEl.className = 'x-episode-asin';
  39.     asinEl.appendChild(text);
  40.  
  41.     let parent = el.querySelector('.dv-el-title-data');
  42.     let before = parent.querySelector('.dv-el-synopsis-wrapper');
  43.     parent.insertBefore(asinEl, before);
  44.   });
  45.  
  46.   // Amazon new style + PrimeVideo
  47.   document.querySelectorAll('.js-node-episode-container > input, .avu-context-card > input').forEach(el => {
  48.     let asin = el.id.replace(/^(?:selector|av-episode-expand-toggle)-/, '');
  49.  
  50.     let asinEl = document.createElement('div');
  51.     let text = document.createTextNode(asin);
  52.     asinEl.className = 'x-episode-asin';
  53.     asinEl.appendChild(text);
  54.  
  55.     el.parentNode.querySelector('.js-eplist-episode, .av-episode-playback, .js-ep-playback-wrapper').appendChild(asinEl);
  56.   });
  57.  
  58.   // Amazon new style + PrimeVideo movies
  59.   let el = document.querySelector('[data-page-title-id]');
  60.   if (el) {
  61.     let asin = el.dataset.pageTitleId;
  62.  
  63.     let asinEl = document.createElement('div');
  64.     let text = document.createTextNode(asin);
  65.     asinEl.className = 'x-page-asin';
  66.     asinEl.appendChild(text);
  67.  
  68.     let after = document.querySelector('.dv-dp-node-synopsis, .av-synopsis');
  69.     after.parentNode.insertBefore(asinEl, after.nextSibling);
  70.   }
  71. }());
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top