Amazon Photo Share Variation

Share Amazon product details to Telegram groups

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/480812/1286402/Amazon%20Photo%20Share%20Variation.js

  1. // ==UserScript==
  2. // @name Amazon Photo Share Variation
  3. // @namespace Violentmonkey Scripts
  4. // @version 0.1
  5. // @description Share Amazon product details to Telegram groups
  6. // @author rfve
  7. // @include /^https?:\/\/(www|smile)\.amazon\.(cn|in|co\.jp|sg|ae|fr|de|it|nl|es|co\.uk|ca|com(\.(mx|au|br|tr))?)\/.*(dp|gp\/(product|video)|exec\/obidos\/ASIN|o\/ASIN)\/.*$/
  8. // @require https://code.jquery.com/jquery-3.6.4.min.js
  9. // @grant GM_xmlhttpRequest
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. const sendPhotoToTelegram = (imageSrc, caption) => {
  16. // Replace 'YOUR_TELEGRAM_BOT_API_KEY' with your bot API key
  17. const apiKey = '8188026:AAE2GAQUfndCUoNVjL5TNAYAWSEAIQ';
  18.  
  19. // Replace 'YOUR_CHAT_IDS' with an array of your chat IDs
  20. const chatIds = ['-1001287724', '-1000329146'];
  21.  
  22. const apiUrl = `https://api.telegram.org/bot${apiKey}/sendPhoto`;
  23.  
  24. chatIds.forEach((chatId) => {
  25. GM_xmlhttpRequest({
  26. method: 'POST',
  27. url: apiUrl,
  28. data: `chat_id=${chatId}&photo=${encodeURIComponent(imageSrc)}&caption=${encodeURIComponent(caption)}`,
  29. headers: {
  30. 'Content-Type': 'application/x-www-form-urlencoded',
  31. },
  32. });
  33. });
  34. };
  35.  
  36. const getProductDetails = () => {
  37. const asin = jQuery("#ASIN").val();
  38. const productName = document.querySelector("#productTitle").textContent.trim();
  39. const productPrice = document.querySelector("#corePrice_feature_div > div > div > span.a-price.aok-align-center > span.a-offscreen").textContent.replace("TL", ' TL');
  40. const productLink = window.location.href;
  41. const productImage = document.querySelector("#landingImage").src;
  42. const ref = 'https://www.amazon.com.tr/dp/' + asin + '?tag=indirimtim_10222-21&smid=A1UNQM1SR2CHM&th=1&psc=1';
  43. const variants = getVariants();
  44. const productDetails = `${productName}\n\n${productPrice}\n\n${ref}\n\n${variants.join('\n')}\n\n#işbirliği`;
  45.  
  46. sendPhotoToTelegram(productImage, productDetails);
  47. };
  48.  
  49. const getVariants = () => {
  50. const variants = [];
  51. const variantItems = document.querySelectorAll('.swatch-list-item-text');
  52.  
  53. variantItems.forEach((item) => {
  54. const size = item.querySelector('.swatch-title-text').innerText.trim();
  55. const priceElement = item.querySelector('.twisterSwatchPrice');
  56. let price = null;
  57.  
  58. if (priceElement) {
  59. price = priceElement.innerText.trim();
  60. }
  61.  
  62. if (price !== null) {
  63. variants.push(`${size} - ${price}`);
  64. }
  65. });
  66.  
  67. return variants;
  68. };
  69.  
  70. // Add a button to the Amazon page
  71. const addButtonToPage = () => {
  72. const buttonContainer = document.createElement('div');
  73. buttonContainer.style.position = 'fixed';
  74. buttonContainer.style.bottom = '20px';
  75. buttonContainer.style.right = '20px';
  76. buttonContainer.style.zIndex = '9999';
  77.  
  78. const shareButton = document.createElement('button');
  79. shareButton.innerText = 'Telegrama Gönder';
  80. shareButton.style.padding = '10px';
  81. shareButton.style.cursor = 'pointer';
  82. shareButton.addEventListener('click', getProductDetails);
  83.  
  84. buttonContainer.appendChild(shareButton);
  85. document.body.appendChild(buttonContainer);
  86. };
  87.  
  88. addButtonToPage();
  89. })();

QingJ © 2025

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