Guest User

Uplay+ activate products

a guest
Sep 11th, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (() => {
  2.     if (uplayData.authenticated !== "true") {
  3.         return;
  4.     }
  5.  
  6.     let triedProducts = {};
  7.     let newActivited = {};
  8.  
  9.     jQuery('button.add-to-library').each((i, el) => {
  10.         const btn = jQuery(el);
  11.         const packageId = btn.data("subscription-package-id");
  12.         const productId = btn.data('product-id');
  13.         const productName = btn.closest('div.card-overlay').data('tc100').productName;
  14.         if (productId != "5b06a39a4e0165fa45ffdcfd") return;
  15.         if (!productId) {
  16.             const tile = btn.parents('product-tile');
  17.             const slide = btn.parents('.pass-page-slide');
  18.             tile.length ? productId = tile.data('itemid') : slide && (productId = slide.data('productId'))
  19.         }
  20.         if (productId && packageId != null && triedProducts[productId] === undefined) {
  21.             triedProducts[productId] = productName;
  22.             let status = "未知错误";
  23.             if ("true" === uplayData.authenticated && null != packageId) {
  24.                 $.ajax({
  25.                     async: false,
  26.                     url: Urls.activateSubscriptionProduct,
  27.                     data: { productID: productId }
  28.                 }).done(function(data) {
  29.                     const result = JSON.parse(data);
  30.                     status = result.success ? "成功添加" : "激活失败";
  31.                 });
  32.             }
  33.             console.log(`${status}  ${productId}  ${productName}`);
  34.         }
  35.     });
  36.     console.log(`Total: ${Object.keys(triedProducts).length}, New Activited: ${Object.keys(newActivited).length}`);
  37. })()
Add Comment
Please, Sign In to add comment