Netflix Plans Fetcher

Get Netflix prices of all countries

  1. // ==UserScript==
  2. // @name Netflix Plans Fetcher
  3. // @description Get Netflix prices of all countries
  4. // @author /u/Wilcooo
  5. // @include https://www.netflix.com/*
  6. // @grant GM_getValue
  7. // @grant GM_setValue
  8. // @run-at document-start
  9. // @version 1
  10. // @namespace /u/Wilcooo
  11. // ==/UserScript==
  12.  
  13. var data = GM_getValue('data',{});
  14.  
  15.  
  16. if (location.pathname.startsWith('/signup')) {
  17.  
  18. // Getting the prices & current country whenever the Netflix site is opened
  19.  
  20. document.addEventListener("DOMContentLoaded", function(event) {
  21.  
  22. var geo = netflix.reactContext.models.signupContext.data.geo.requestCountry,
  23. options = netflix.reactContext.models.signupContext.data.flow.fields.planChoice.options;
  24.  
  25. data[geo.id] = {geo:geo, options:options};
  26. GM_setValue('data',data);
  27.  
  28. // Get the exchange rates (used later)
  29. var exchange_rates = jQuery.getJSON("https://www.floatrates.com/daily/usd.json");
  30.  
  31.  
  32. // Write the result info:
  33.  
  34. document.body.innerHTML =
  35. 'Done! You can select another country now.<br><br>' +
  36. 'You can disable this userscript in your userscript manager (f.e. Tampermonkey). You can usually find its icon in the top right.<br><br>' +
  37. 'This is all collected data so far, you can copypasta this table right into EXCEL<br>' +
  38. 'Click <a href="#" onclick="NPFclear()">here</a> to remove everything.<br>'+
  39. 'For more details, type NPFdata in the JS console.<br><br>';
  40.  
  41.  
  42. // Create the table:
  43.  
  44. var table = document.createElement('table');
  45. document.body.appendChild(table);
  46. table.innerHTML = "<tr><th>Country</th><th>Currency</th><th>Basic</th><th>Standard</th><th>Premium</th><th>Basic (USD)</th><th>Standard (USD)</th><th>Premium (USD)</th></tr>"
  47.  
  48.  
  49. // Add all entries to the table
  50.  
  51. Object.keys(data).forEach(function(k) {
  52.  
  53. var currency = data[k].options[0].fields.planPriceCurrency.value;
  54. var prices = data[k].options.map(o => o.fields.planPriceAmount.value || o.fields.planPrice.value.match(/[\d.,]+/)[0] );
  55.  
  56. var tr = data[k].tr = document.createElement("tr");
  57. table.appendChild(tr);
  58. tr.innerHTML = [data[k].geo.countryName, currency, ...prices].map( x => "<td>" + x + "</td>").join('');
  59.  
  60.  
  61. // Once the exchange rates (requested before) are loaded, calculate & add the converted prices:
  62.  
  63. exchange_rates.done(function(exchange_rates) {
  64. try {
  65. var pricesUSD = prices.map( price => (price / exchange_rates[currency.toLowerCase()].rate).toFixed(2) );
  66. tr.innerHTML += pricesUSD.map( x => "<td>" + x + "</td>").join('');
  67. } catch(e){
  68. if (currency.toLowerCase() == "usd") {
  69. tr.innerHTML += prices.map( x => "<td>" + x + "</td>").join('');
  70. } else tr.innerHTML += "<td>Error getting Exchange Rate</td>";
  71. }
  72. });
  73. });
  74.  
  75. });
  76.  
  77. } else location.href = 'https://www.netflix.com/signup/';
  78.  
  79.  
  80. // The function that clears all entries
  81.  
  82. window.NPFclear = function() {
  83. if (confirm("Ara you sure you want to delete everything???")) {
  84. GM_setValue('data',{});
  85. location.href = 'https://www.netflix.com/signup/';
  86. }
  87. }
  88.  
  89.  
  90. // Some styling (CSS) of the table
  91.  
  92. var style = document.createElement('style');
  93. document.head.appendChild(style);
  94. style.sheet.insertRule(` td { border: 1px solid black; width: 80px; }`);
  95.  
  96.  
  97. // Make the data accessible in the JS console
  98. window.NPFdata = data;

QingJ © 2025

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