淘补贴

获取淘宝隐藏补贴,打开淘宝客户端浏览商品,复制商品链接到浏览器打开即可领取补贴购买商品

  1. // ==UserScript==
  2. // @name 淘补贴
  3. // @name:en Tao Butie
  4. // @namespace taobutie.com
  5. // @version 1.1.7
  6. // @description:en To get hidden subsidies on Taobao, open the Taobao app and browse the products. Copy the product link and open it in the browser to claim the subsidy and purchase the item
  7. // @description 获取淘宝隐藏补贴,打开淘宝客户端浏览商品,复制商品链接到浏览器打开即可领取补贴购买商品
  8. // @author Coupon Maker
  9. // @match *://*.taobao.com/search/*
  10. // @match *://*.taobao.com/*
  11. // @match *://*.tmall.com/*
  12. // @match *://*.tb.com/*
  13. // @icon https://res.stayfork.app/images/cms/tqq-script-icon.png
  14. // @grant GM_addStyle
  15. // @grant GM_setValue
  16. // @grant GM_getValue
  17. // @grant GM_registerMenuCommand
  18. // @grant GM_xmlhttpRequest
  19. // @run-at document-start
  20. // @license CC BY-ND 4.0
  21. // ==/UserScript==
  22. (function () {
  23. 'use strict';
  24. const TaoQQUtils = {
  25. generateUuid: function(len, radix) {
  26. len = !len ? 32 : (len > 32 ? 32 : len);
  27. let chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
  28. let uuid = [], i;
  29. radix = !radix ? chars.length : (radix > chars.length ? chars.length : radix);
  30. if (len) {
  31. // Compact form
  32. for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
  33. } else {
  34. // rfc4122, version 4 form
  35. let r;
  36. // rfc4122 requires these characters
  37. uuid[8] = uuid[13] = uuid[18] = uuid[23] = '_';
  38. uuid[14] = '4';
  39. // Fill in random data. At i==19 set the high bits of clock sequence as
  40. // per rfc4122, sec. 4.1.5
  41. for (i = 0; i < 36; i++) {
  42. if (!uuid[i]) {
  43. r = 0 | Math.random() * 16;
  44. uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
  45. }
  46. }
  47. }
  48. return uuid.join('');
  49. },
  50. computFloat: function(number){
  51. let numberStr = number.toString();
  52. let parts = numberStr.split('.');
  53. if (parts.length === 2) {
  54. const fnum = parseInt(parts[1], 10);
  55. if(fnum>=10){
  56. return fnum.toString();
  57. }else{
  58. return `0${fnum}`;
  59. }
  60. }
  61. return "00";
  62. },
  63. computWan: function(volume){
  64. if(typeof volume == "undefined"){
  65. return "0";
  66. }
  67. let wan = volume / 10000;
  68. if(wan >= 1 ){
  69. return `${wan}万+`
  70. }
  71. wan = volume / 1000;
  72. if(wan >= 1 ){
  73. return `${wan}000+`
  74. }
  75. wan = volume / 100;
  76. if(wan >= 1 ){
  77. return `${wan}00+`
  78. }
  79. wan = volume / 10;
  80. if(wan >= 1 ){
  81. return `${wan}0+`
  82. }else{
  83. return `${volume}`;
  84. }
  85. },
  86. getUserDeviceId: function(){
  87. const userDeviceId = window.localStorage.getItem("__cc_device_stay_quan_") || TaoQQUtils.generateUuid();
  88. window.localStorage.setItem("__cc_device_stay_quan_", userDeviceId);
  89. return userDeviceId;
  90. },
  91. replaceUrlArg: function (url, arg, argVal){
  92. const urlObj = new URL(url);
  93. urlObj.searchParams.set(arg, argVal)
  94. return urlObj.href
  95. },
  96. queryURLParams: (url="", name="") => {
  97. var pattern = new RegExp("[?&#]+" + name + "=([^?&#]+)");
  98. var res = pattern.exec(url);
  99. if (!res) return;
  100. if (!res[1]) return;
  101. return res[1];
  102. },
  103. isIpad: function(){
  104. const userAgentInfo = navigator.userAgent;
  105. let Agents = ['iPad'];
  106. let getArr = Agents.filter(i => userAgentInfo.toLowerCase().includes(i.toLowerCase()));
  107. let isIpad = getArr.length ? true : false;
  108. if(isIpad){
  109. return isIpad
  110. }else{
  111. if (userAgentInfo.match(/Macintosh/) && navigator.maxTouchPoints > 1) {
  112. return true;
  113. }
  114. }
  115. return isIpad;
  116. },
  117. isMobile: function(){
  118. const userAgentInfo = navigator.userAgent;
  119. let Agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPod', 'HarmonyOS'];
  120. let getArr = Agents.filter(i => userAgentInfo.toLowerCase().includes(i.toLowerCase()));
  121. return getArr.length ? true : false;
  122. },
  123. isNumber: (inputData) => {
  124. //isNaN(inputData)不能判断空串或一个空格
  125. //如果是一个空串或是一个空格,而isNaN是做为数字0进行处理的,
  126. //而parseInt与parseFloat是返回一个错误消息,这个isNaN检查不严密而导致的。
  127. if (parseFloat(inputData).toString() == "NaN") {
  128. //alert(“请输入数字……”);
  129. return false;
  130. }else {
  131. return true;
  132. }
  133. },
  134. setUserAgentInfo: (agentInfo) => {
  135. Object.defineProperty(navigator, 'userAgent', {
  136. value: agentInfo,
  137. writable: false
  138. });
  139. },
  140. isMobileTbHome: () => {
  141. return window.location.pathname == "/" && TaoQQUtils.isMobile();
  142. },
  143. checkPage: () => {
  144. const pageUrl = window.location.href;
  145. // console.log("window.location.host-----", window.location.host, window.location.href);
  146. if(pageUrl.match(/taobao.com\/search/) || TaoQQUtils.isMobileTbHome()){
  147. return "list_page";
  148. }else{
  149. const itemId = TaoQQUtils.queryURLParams(hrefUrl, "id");
  150. if(itemId){
  151. return "detail_page"
  152. }else{
  153. // check quan page
  154. if(window.location.host.indexOf("uland.taobao.com") > -1){
  155. return "quan_page"
  156. }else{
  157. return "unknown"
  158. }
  159. }
  160. }
  161. },
  162. md5: (str) => {
  163. /**
  164. * Add integers, wrapping at 2^32.
  165. * This uses 16-bit operations internally to work around bugs in interpreters.
  166. *
  167. * @param {number} x First integer
  168. * @param {number} y Second integer
  169. * @returns {number} Sum
  170. */
  171. function safeAdd(x, y) {
  172. var lsw = (x & 0xffff) + (y & 0xffff)
  173. var msw = (x >> 16) + (y >> 16) + (lsw >> 16)
  174. return (msw << 16) | (lsw & 0xffff)
  175. }
  176. /**
  177. * Bitwise rotate a 32-bit number to the left.
  178. *
  179. * @param {number} num 32-bit number
  180. * @param {number} cnt Rotation count
  181. * @returns {number} Rotated number
  182. */
  183. function bitRotateLeft(num, cnt) {
  184. return (num << cnt) | (num >>> (32 - cnt))
  185. }
  186. /**
  187. * Basic operation the algorithm uses.
  188. *
  189. * @param {number} q q
  190. * @param {number} a a
  191. * @param {number} b b
  192. * @param {number} x x
  193. * @param {number} s s
  194. * @param {number} t t
  195. * @returns {number} Result
  196. */
  197. function md5cmn(q, a, b, x, s, t) {
  198. return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b)
  199. }
  200. /**
  201. * Basic operation the algorithm uses.
  202. *
  203. * @param {number} a a
  204. * @param {number} b b
  205. * @param {number} c c
  206. * @param {number} d d
  207. * @param {number} x x
  208. * @param {number} s s
  209. * @param {number} t t
  210. * @returns {number} Result
  211. */
  212. function md5ff(a, b, c, d, x, s, t) {
  213. return md5cmn((b & c) | (~b & d), a, b, x, s, t)
  214. }
  215. /**
  216. * Basic operation the algorithm uses.
  217. *
  218. * @param {number} a a
  219. * @param {number} b b
  220. * @param {number} c c
  221. * @param {number} d d
  222. * @param {number} x x
  223. * @param {number} s s
  224. * @param {number} t t
  225. * @returns {number} Result
  226. */
  227. function md5gg(a, b, c, d, x, s, t) {
  228. return md5cmn((b & d) | (c & ~d), a, b, x, s, t)
  229. }
  230. /**
  231. * Basic operation the algorithm uses.
  232. *
  233. * @param {number} a a
  234. * @param {number} b b
  235. * @param {number} c c
  236. * @param {number} d d
  237. * @param {number} x x
  238. * @param {number} s s
  239. * @param {number} t t
  240. * @returns {number} Result
  241. */
  242. function md5hh(a, b, c, d, x, s, t) {
  243. return md5cmn(b ^ c ^ d, a, b, x, s, t)
  244. }
  245. /**
  246. * Basic operation the algorithm uses.
  247. *
  248. * @param {number} a a
  249. * @param {number} b b
  250. * @param {number} c c
  251. * @param {number} d d
  252. * @param {number} x x
  253. * @param {number} s s
  254. * @param {number} t t
  255. * @returns {number} Result
  256. */
  257. function md5ii(a, b, c, d, x, s, t) {
  258. return md5cmn(c ^ (b | ~d), a, b, x, s, t)
  259. }
  260. /**
  261. * Calculate the MD5 of an array of little-endian words, and a bit length.
  262. *
  263. * @param {Array} x Array of little-endian words
  264. * @param {number} len Bit length
  265. * @returns {Array<number>} MD5 Array
  266. */
  267. function binlMD5(x, len) {
  268. /* append padding */
  269. x[len >> 5] |= 0x80 << len % 32
  270. x[(((len + 64) >>> 9) << 4) + 14] = len
  271.  
  272. var i
  273. var olda
  274. var oldb
  275. var oldc
  276. var oldd
  277. var a = 1732584193
  278. var b = -271733879
  279. var c = -1732584194
  280. var d = 271733878
  281.  
  282. for (i = 0; i < x.length; i += 16) {
  283. olda = a
  284. oldb = b
  285. oldc = c
  286. oldd = d
  287.  
  288. a = md5ff(a, b, c, d, x[i], 7, -680876936)
  289. d = md5ff(d, a, b, c, x[i + 1], 12, -389564586)
  290. c = md5ff(c, d, a, b, x[i + 2], 17, 606105819)
  291. b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330)
  292. a = md5ff(a, b, c, d, x[i + 4], 7, -176418897)
  293. d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426)
  294. c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341)
  295. b = md5ff(b, c, d, a, x[i + 7], 22, -45705983)
  296. a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416)
  297. d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417)
  298. c = md5ff(c, d, a, b, x[i + 10], 17, -42063)
  299. b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162)
  300. a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682)
  301. d = md5ff(d, a, b, c, x[i + 13], 12, -40341101)
  302. c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290)
  303. b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329)
  304.  
  305. a = md5gg(a, b, c, d, x[i + 1], 5, -165796510)
  306. d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632)
  307. c = md5gg(c, d, a, b, x[i + 11], 14, 643717713)
  308. b = md5gg(b, c, d, a, x[i], 20, -373897302)
  309. a = md5gg(a, b, c, d, x[i + 5], 5, -701558691)
  310. d = md5gg(d, a, b, c, x[i + 10], 9, 38016083)
  311. c = md5gg(c, d, a, b, x[i + 15], 14, -660478335)
  312. b = md5gg(b, c, d, a, x[i + 4], 20, -405537848)
  313. a = md5gg(a, b, c, d, x[i + 9], 5, 568446438)
  314. d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690)
  315. c = md5gg(c, d, a, b, x[i + 3], 14, -187363961)
  316. b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501)
  317. a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467)
  318. d = md5gg(d, a, b, c, x[i + 2], 9, -51403784)
  319. c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473)
  320. b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734)
  321.  
  322. a = md5hh(a, b, c, d, x[i + 5], 4, -378558)
  323. d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463)
  324. c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562)
  325. b = md5hh(b, c, d, a, x[i + 14], 23, -35309556)
  326. a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060)
  327. d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353)
  328. c = md5hh(c, d, a, b, x[i + 7], 16, -155497632)
  329. b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640)
  330. a = md5hh(a, b, c, d, x[i + 13], 4, 681279174)
  331. d = md5hh(d, a, b, c, x[i], 11, -358537222)
  332. c = md5hh(c, d, a, b, x[i + 3], 16, -722521979)
  333. b = md5hh(b, c, d, a, x[i + 6], 23, 76029189)
  334. a = md5hh(a, b, c, d, x[i + 9], 4, -640364487)
  335. d = md5hh(d, a, b, c, x[i + 12], 11, -421815835)
  336. c = md5hh(c, d, a, b, x[i + 15], 16, 530742520)
  337. b = md5hh(b, c, d, a, x[i + 2], 23, -995338651)
  338.  
  339. a = md5ii(a, b, c, d, x[i], 6, -198630844)
  340. d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415)
  341. c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905)
  342. b = md5ii(b, c, d, a, x[i + 5], 21, -57434055)
  343. a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571)
  344. d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606)
  345. c = md5ii(c, d, a, b, x[i + 10], 15, -1051523)
  346. b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799)
  347. a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359)
  348. d = md5ii(d, a, b, c, x[i + 15], 10, -30611744)
  349. c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380)
  350. b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649)
  351. a = md5ii(a, b, c, d, x[i + 4], 6, -145523070)
  352. d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379)
  353. c = md5ii(c, d, a, b, x[i + 2], 15, 718787259)
  354. b = md5ii(b, c, d, a, x[i + 9], 21, -343485551)
  355.  
  356. a = safeAdd(a, olda)
  357. b = safeAdd(b, oldb)
  358. c = safeAdd(c, oldc)
  359. d = safeAdd(d, oldd)
  360. }
  361. return [a, b, c, d]
  362. }
  363. /**
  364. * Convert an array of little-endian words to a string
  365. *
  366. * @param {Array<number>} input MD5 Array
  367. * @returns {string} MD5 string
  368. */
  369. function binl2rstr(input) {
  370. var i
  371. var output = ''
  372. var length32 = input.length * 32
  373. for (i = 0; i < length32; i += 8) {
  374. output += String.fromCharCode((input[i >> 5] >>> i % 32) & 0xff)
  375. }
  376. return output
  377. }
  378. /**
  379. * Convert a raw string to an array of little-endian words
  380. * Characters >255 have their high-byte silently ignored.
  381. *
  382. * @param {string} input Raw input string
  383. * @returns {Array<number>} Array of little-endian words
  384. */
  385. function rstr2binl(input) {
  386. var i
  387. var output = []
  388. output[(input.length >> 2) - 1] = undefined
  389. for (i = 0; i < output.length; i += 1) {
  390. output[i] = 0
  391. }
  392. var length8 = input.length * 8
  393. for (i = 0; i < length8; i += 8) {
  394. output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << i % 32
  395. }
  396. return output
  397. }
  398. /**
  399. * Calculate the MD5 of a raw string
  400. *
  401. * @param {string} s Input string
  402. * @returns {string} Raw MD5 string
  403. */
  404. function rstrMD5(s) {
  405. return binl2rstr(binlMD5(rstr2binl(s), s.length * 8))
  406. }
  407. /**
  408. * Encode a string as UTF-8
  409. *
  410. * @param {string} input Input string
  411. * @returns {string} UTF8 string
  412. */
  413. function str2rstrUTF8(input) {
  414. return unescape(encodeURIComponent(input))
  415. }
  416. /**
  417. * Encodes input string as raw MD5 string
  418. *
  419. * @param {string} s Input string
  420. * @returns {string} Raw MD5 string
  421. */
  422. function rawMD5(s) {
  423. return rstrMD5(str2rstrUTF8(s))
  424. }
  425. /**
  426. * Convert a raw string to a hex string
  427. *
  428. * @param {string} input Raw input string
  429. * @returns {string} Hex encoded string
  430. */
  431. function rstr2hex(input) {
  432. var hexTab = '0123456789abcdef'
  433. var output = ''
  434. var x
  435. var i
  436. for (i = 0; i < input.length; i += 1) {
  437. x = input.charCodeAt(i)
  438. output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f)
  439. }
  440. return output
  441. }
  442. return rstr2hex(rawMD5(str))
  443. },
  444. parseToDOM(str){
  445. let divDom = document.createElement('template');
  446. if(typeof str == 'string'){
  447. divDom.innerHTML = str;
  448. return divDom.content;
  449. }
  450. return str;
  451. },
  452. }
  453. const hrefUrl = window.location.href;
  454. console.log("hrefUrl-----",hrefUrl, ",userDeviceId--",TaoQQUtils.getUserDeviceId());
  455. const switchOff = false;
  456. // GM_getValue("tao_quan_quan_switch_off") || false;
  457. // console.log("hrefUrl-----",hrefUrl, ",userDeviceId--",TaoQQUtils.getUserDeviceId());
  458.  
  459. // GM_registerMenuCommand("打开/关闭推荐", ()=>{
  460. // if(switchOff){
  461. // GM_setValue("tao_quan_quan_switch_off", false)
  462. // }else{
  463. // GM_setValue("tao_quan_quan_switch_off", true)
  464. // }
  465. // window.location.reload(true);
  466. // })
  467.  
  468. // if(switchOff){
  469. // return;
  470. // }
  471.  
  472. function addLoginListener(){
  473. if(window.top != window && (window.location.href.indexOf("login")> -1 || window.location.href.indexOf("third-party-cookie")> -1)){
  474. let jumpUrl = window.location.href;
  475. if(!TaoQQUtils.isMobile()){
  476. jumpUrl = TaoQQUtils.replaceUrlArg(jumpUrl, "style", "1");
  477. }
  478. window.top.postMessage({action: 'login', jump: jumpUrl}, "*");
  479. return;
  480. }
  481. }
  482. addLoginListener();
  483.  
  484. let __style = `
  485. :root {
  486. --s-icon-block: #2F3134;
  487. --quan-bg: #ffffff;
  488. }
  489. @media (prefers-color-scheme: dark) {
  490. :root {
  491. --s-icon-block: #DCDCDC;
  492. --quan-bg: #1C1C1C;
  493. }
  494. }
  495. a[check-quan="true"]{
  496. position: relative;
  497. }
  498. .s8t9a0i8y66-quan-box{
  499. display: flex;
  500. justify-content: center;
  501. align-items: center;
  502. box-sizing: border-box;
  503. }
  504. .s8t9a0i8y66-detail-p-quan{
  505. justify-content: flex-start!important;
  506. height: 34px;
  507. }
  508. .s8t9a0i8y66-detail-m-quan{
  509. height:20px;
  510. overflow:hidden;
  511. margin-top: 10px;
  512. justify-content: flex-start;
  513. top: 0px;
  514. }
  515. .s8t9a0i8y66-detail-m-fixed{
  516. position: fixed;
  517. z-index: 66;
  518. left: 0;
  519. top: 50%;
  520. transform: translate(0, -50%);
  521. }
  522. .s8t9a0i8y66-detail-pc-abs{
  523. position: absolute;
  524. right: 100px;
  525. top: 165px;
  526. }
  527. .s8t9a0i8y66-detail-pc-fixed{
  528. position: fixed;
  529. z-index: 66;
  530. right: 52px;
  531. top: 30%;
  532. }
  533. .s8t9a0i8y66-detail-m-quan .s8t9a0i8y66-detail-quan-item{
  534. font-size: 14px;
  535. }
  536. .s8t9a0i8y66-detail-quan-item{
  537. position: relative;
  538. border: 1px solid #E02020;
  539. background: #E02020;
  540. color:#ffffff;
  541. font-size: 14px;
  542. padding: 2px 5px;
  543. text-align: center;
  544. border-radius: 2px;
  545. display: flex;
  546. justify-content: center;
  547. align-items: center;
  548. box-sizing: border-box;
  549. margin-right:5px;
  550. cursor: default;
  551. }
  552. .s8t9a0i8y66-detail-quan-item .s8t9a0i8y66-tlj-confirm{
  553. color:#ffffff;
  554. font-size: 14px;
  555. padding-left: 4px;
  556. }
  557. .s8t9a0i8y66-m-awp{
  558. padding: 0 14px;
  559. background-color: rgb(255, 255, 255);
  560. margin: 0px 10px;
  561. height: 30px;
  562. align-items: end;
  563. }
  564. .s8t9a0i8y66-quan-corner-box{
  565. position: absolute;
  566. top: 3px;
  567. right: 3px;
  568. overflow:hidden;
  569. z-index:889;
  570. padding: 5px 10px;
  571. background-color: rgba(0, 0, 0, 0.5);
  572. border-bottom-left-radius: 10px;
  573. border-top-left-radius: 10px;
  574. display: flex;
  575. flex-direction: column;
  576. justify-content: center;
  577. align-items: center;
  578. box-sizing: border-box;
  579. }
  580. .s8t9a0i8y66-quan-item{
  581. position: relative;
  582. // overflow:hidden;
  583. color:#ffffff;
  584. font-size: 12px;
  585. text-align: center;
  586. }
  587. .s8t9a0i8y66-quan-item .s8t9a0i8y66-yuan{
  588. font-size: 12px;
  589. }
  590. .s8t9a0i8y66-m-quan{
  591. height:18.6px;
  592. margin-top: 0.5333vw;
  593. }
  594. .s8t9a0i8y66-m-quan-item{
  595. position: relative;
  596. border: 1px solid #E02020;
  597. background: #E02020;
  598. // max-width:80px;
  599. height:18px;
  600. overflow:hidden;
  601. color:#ffffff;
  602. font-size: 11px;
  603. padding: 0 2px;
  604. text-align: center;
  605. border-radius: 2px;
  606. display: flex;
  607. justify-content: center;
  608. align-items: center;
  609. box-sizing: border-box;
  610. margin-right: 0.8vw;
  611. margin-top: 0.5333vw;
  612. vertical-align: middle;
  613. line-height: 3.7333vw;
  614. }
  615. .s8t9a0i8y66-quan-amount{
  616. font-size: 14px;
  617. }
  618. .s8t9a0i8y66-yuan{
  619. font-size:10px; padding-left:3px; position: relative; top: 0px;
  620. }
  621. .s8t9a0i8y66-m-quan-item .s8t9a0i8y66-quan-amount{
  622. font-size: 11px;
  623. }
  624. .s8t9a0i8y66-m-quan-item .s8t9a0i8y66-yuan{
  625. top: 1px;
  626. }
  627. // for detail
  628. .bottombarRight{
  629. position: relative;
  630. }
  631. .s8t9a0i8y66-bottom-action{
  632. position: absolute;
  633. left: 0;
  634. top: 0;
  635. width: 100%;
  636. height: 100%;
  637. display: flex;
  638. justify-content: center;
  639. align-items: center;
  640. z-index: 99999;
  641. }
  642. .s8t9a0i8y66-m-action{
  643. height: 10.66667vw!important;
  644. }
  645. .s8t9a0i8y66-m-action .s8t9a0i8y66-action-item{
  646. height: 10.66667vw;
  647. }
  648. .s8t9a0i8y66-action-item{
  649. height: 100%;
  650. width: 50%;
  651. display: flex;
  652. flex-direction: column;
  653. justify-content: center;
  654. align-items: center;
  655. box-sizing: border-box;
  656. // color: #ffffff;
  657. color: transparent;
  658. }
  659. .s8t9a0i8y66-joincar{
  660. // background: #EB6868;
  661. background: transparent;
  662. }
  663. .s8t9a0i8y66-m-action .s8t9a0i8y66-joincar{
  664. border-top-left-radius: 5.33333vw;
  665. border-bottom-left-radius: 5.33333vw;
  666. }
  667. .s8t9a0i8y66-p-action .s8t9a0i8y66-joincar{
  668. border-top-left-radius: 8px;
  669. border-bottom-left-radius: 8px;
  670. }
  671. .s8t9a0i8y66-bynow{
  672. // background: #E02020;
  673. background: transparent;
  674. }
  675. .s8t9a0i8y66-m-action .s8t9a0i8y66-bynow{
  676. border-top-right-radius: 5.33333vw;
  677. border-bottom-right-radius: 5.33333vw;
  678. }
  679. .s8t9a0i8y66-p-action .s8t9a0i8y66-bynow{
  680. border-top-right-radius: 8px;
  681. border-bottom-right-radius: 8px;
  682. }
  683. .s8t9a0i8y66-label{
  684. font-size: 14px;
  685. // color: #ffffff;
  686. color: transparent;
  687. }
  688. .s8t9a0i8y66-label10{
  689. font-size: 10px;
  690. position:relative;
  691. line-height: 15px;
  692. }
  693. .s8t9a0i8y66-l-12{
  694. left: -12px;
  695. }
  696. .s8t9a0i8y66-l-3{
  697. left: -3px;
  698. }
  699. .s8t9a0i8y66-quan-modal-box{
  700. position:fixed;
  701. z-index:2147483647;
  702. top:0;
  703. left:0;
  704. width:100%;
  705. height:100%;
  706. background: rgba(0,0,0,0.5);
  707. }
  708. .s8t9a0i8y66-quan-modal{
  709. box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.08);
  710. position:fixed;
  711. z-index:2147483647;
  712. top:50%;
  713. left:50%;
  714. transform: translate(-50%, -50%);
  715. width: 320px;
  716. height: 580px;
  717. border-radius: 10px;
  718. background: #ffffff;
  719. padding-top:40px;
  720. box-sizing: border-box;
  721. overflow: hidden;
  722. }
  723. .s8t9a0i8y66-quan-modal-title{
  724. position:fixed;
  725. z-index:2147483647;
  726. overflow: hidden;
  727. left: 20px;
  728. top: 5px;
  729. width:300px;
  730. height:30px;
  731. font-size: 17px;
  732. color: var(--s-icon-block);
  733. line-height: 30px;
  734. font-weight: 500;
  735. }
  736. /* 创建一个容器 */
  737. .s8t9a0i8y66-quan-close-con {
  738. position:fixed;
  739. z-index:2147483647;
  740. overflow: hidden;
  741. right: 5px;
  742. top: 5px;
  743. width:30px;
  744. height:30px;
  745. background: var(--quan-bg);
  746. border-radius:50%;
  747. user-select: none;
  748. cursor: pointer;
  749. }
  750.  
  751. /* 创建第一条斜线 */
  752. .s8t9a0i8y66-quan-close-con::before,
  753. .s8t9a0i8y66-quan-close-con::after {
  754. content: '';
  755. position: absolute;
  756. top: 50%;
  757. left: 50%;
  758. width: 20px; /* 斜线的宽度 */
  759. height: 2px; /* 斜线的高度 */
  760. background-color: var(--s-icon-block); /* 斜线的颜色 */
  761. }
  762.  
  763. /* 旋转45度,形成斜线 */
  764. .s8t9a0i8y66-quan-close-con::before {
  765. transform: translate(-50%, -50%) rotate(45deg);
  766. }
  767.  
  768. /* 旋转-45度,形成另一条斜线 */
  769. .s8t9a0i8y66-quan-close-con::after {
  770. transform: translate(-50%, -50%) rotate(-45deg);
  771. }
  772. .s8t9a0i8y66-quan-mask{
  773. position:fixed;
  774. z-index:99999;
  775. overflow: hidden;
  776. left:0;
  777. top:0;
  778. width:100%;
  779. height:100%;
  780. // background: rgba(255,255,255,0.8);
  781. display: flex;
  782. justify-content: center;
  783. align-items: center;
  784. border-radius: 10px;
  785. backdrop-filter: blur(10px);
  786. }
  787. .s8t9a0i8y66-quan-modal iframe{
  788. border-radius: 10px;
  789. border: none;
  790. padding: 0;
  791. margin: 0;
  792. position: relative;
  793. z-index: 999999;
  794. overflow: hidden;
  795. scrollbar-width: none; /* Firefox */
  796. }
  797. .s8t9a0i8y66-quan-modal iframe::-webkit-scrollbar {
  798. display: none; /* Chrome, Safari and Opera */
  799. }
  800. .s8t9a0i8y66-quan-modal .s8t9a0i8y66-quan-none{
  801. border-radius: 10px;
  802. border: none;
  803. padding: 0;
  804. margin: 0;
  805. position: relative;
  806. z-index: 999999;
  807. color: var(--s-icon-block);
  808. font-size: 18px;
  809. width:100%;
  810. height: 100%;
  811. background: #fff;
  812. display: flex;
  813. justify-content: center;
  814. align-items: center;
  815. }
  816. .s8t9a0i8y66-loading-dots {
  817. display: inline-block;
  818. }
  819. .s8t9a0i8y66-black span{
  820. background-color: #333;
  821. }
  822. .s8t9a0i8y66-white span{
  823. background-color: #ffffff;
  824. }
  825. .s8t9a0i8y66-loading-dots span {
  826. display: inline-block;
  827. width: 8px;
  828. height: 8px;
  829. margin: 0 2px;
  830. border-radius: 50%;
  831. animation: loading 1.2s infinite ease-in-out both;
  832. }
  833. .s8t9a0i8y66-loading-dots span:nth-child(1) {
  834. animation-delay: -0.32s;
  835. }
  836. .s8t9a0i8y66-loading-dots span:nth-child(2) {
  837. animation-delay: -0.16s;
  838. }
  839. .s8t9a0i8y66-toast {
  840. visibility: hidden;
  841. min-width: 250px;
  842. max-width: 300px;
  843. background-color: rgba(0,0,0,0.75);
  844. color: #fff;
  845. text-align: center;
  846. border-radius: 5px;
  847. padding: 16px;
  848. position: fixed;
  849. z-index: 99;
  850. left: 50%;
  851. top: 50%;
  852. transform: translate(-50%, -50%);
  853. font-size: 17px;
  854. opacity: 0;
  855. transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
  856. }
  857.  
  858. .s8t9a0i8y66-toast.s8t9a0i8y66-show {
  859. visibility: visible;
  860. opacity: 1;
  861. }
  862. .s8t9a0i8y66-loading-pannel.s8t9a0i8y66-loading-pannel-show {
  863. visibility: visible;
  864. opacity: 1;
  865. }
  866.  
  867. .s8t9a0i8y66-loading-pannel{
  868. visibility: hidden;
  869. width: 100%;
  870. height: 100%;
  871. background-color: rgba(0,0,0,0.5);
  872. text-align: center;
  873. position: fixed;
  874. z-index: 99;
  875. left: 0;
  876. top: 0;
  877. opacity: 0;
  878. display: flex;
  879. flex-direction: column;
  880. align-items: center;
  881. justify-content: center;
  882. transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
  883. }
  884. .s8t9a0i8y66-loading-msg{
  885. color: #fff;
  886. font-size: 17px;
  887. text-align: center;
  888. max-width: 300px;
  889. }
  890. @keyframes loading {
  891. 0%, 80%, 100% {
  892. transform: scale(0);
  893. }
  894. 40% {
  895. transform: scale(1);
  896. }
  897. }
  898.  
  899. `;
  900.  
  901. GM_addStyle(__style);
  902.  
  903. const loadingHtml = (scale, bgColor) => {
  904. scale = scale || 1;
  905. bgColor = bgColor ? `s8t9a0i8y66-${bgColor}` : "s8t9a0i8y66-black";
  906. return `<div class="s8t9a0i8y66-loading-dots ${bgColor}" style="zoom: ${scale}; '-moz-transform': scale(${scale}); '-moz-transform-origin': ${scale}"><span></span><span></span><span></span></div>`;
  907. }
  908. const listPageAHref = "a[href*='/item.htm']:not([check-quan]), a[href*='/detail.htm']:not([check-quan]), a[href^='https://a.m.taobao.com/i']:not([check-quan])"
  909. // if(TaoQQUtils.isMobile()){
  910. // const customUserAgent = 'Mozilla/5.0 (Linux; U; Android 7.0; zh-CN; PRO 7-S Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 UCBrowser/11.9.4.974 UWS/2.13.2.46 Mobile Safari/537.36 AliApp(DingTalk/4.6.29) com.alibaba.android.rimet/11388461 Channel/10002068 language/zh-CN';
  911. // // console.log("isMobile to set userAgent")
  912. // TaoQQUtils.setUserAgentInfo(customUserAgent);
  913. // // __style = __style + `body{margin-top:148px!important;}`;
  914. // }
  915.  
  916.  
  917. function generateSign(param, timestamp){
  918. const before = `TOBEBESTENG${param}${timestamp}`;
  919. return TaoQQUtils.md5(before);
  920. }
  921.  
  922. function createToast(){
  923. let toastDom = document.querySelector("#s8t9a0i8y66_toast");
  924. if(toastDom){
  925. return toastDom;
  926. }else{
  927. toastDom = document.createElement("div");
  928. toastDom.id = "s8t9a0i8y66_toast";
  929. toastDom.classList.add("s8t9a0i8y66-toast");
  930. document.body.appendChild(toastDom);
  931. }
  932. return toastDom;
  933. }
  934.  
  935. function showToast(message, delayed){
  936. delayed = delayed || 2000;
  937. const toastDom = createToast();
  938. toastDom.innerText = message;
  939. toastDom.className = "s8t9a0i8y66-toast s8t9a0i8y66-show";
  940. let toastTime = setTimeout(function() {
  941. toastDom.className = "s8t9a0i8y66-toast";
  942. clearTimeout(toastTime);
  943. toastTime = null;
  944. }, delayed);
  945. }
  946.  
  947. function createLoadingPannel(){
  948. let loadingPannelDom = document.querySelector("#s8t9a0i8y66_loading_pannel");
  949. if(loadingPannelDom){
  950. return loadingPannelDom;
  951. }else{
  952. const loadingDomArr = [
  953. `<div class='s8t9a0i8y66-loading-pannel' id='s8t9a0i8y66_loading_pannel'>`,
  954. `<div class='s8t9a0i8y66-loading-msg'></div>`,
  955. loadingHtml(0.7, "white"),
  956. "</div>"
  957. ];
  958. document.body.appendChild(TaoQQUtils.parseToDOM(loadingDomArr.join("")));
  959. loadingPannelDom = document.querySelector("#s8t9a0i8y66_loading_pannel");
  960. }
  961. return loadingPannelDom;
  962. }
  963.  
  964. function showLoadingPannel(message){
  965. const loadingPannelDom = createLoadingPannel();
  966. loadingPannelDom.querySelector(".s8t9a0i8y66-loading-msg") && (loadingPannelDom.querySelector(".s8t9a0i8y66-loading-msg").innerText = message);
  967. loadingPannelDom.className = "s8t9a0i8y66-loading-pannel s8t9a0i8y66-loading-pannel-show";
  968. }
  969.  
  970. function hiddenLoadingPannel(){
  971. let loadingPannelDom = document.querySelector("#s8t9a0i8y66_loading_pannel");
  972. if(loadingPannelDom){
  973. loadingPannelDom.querySelector(".s8t9a0i8y66-loading-msg") && (loadingPannelDom.querySelector(".s8t9a0i8y66-loading-msg").innerText = "");
  974. loadingPannelDom.className = "s8t9a0i8y66-loading-pannel";
  975. }
  976. }
  977.  
  978. function fetchItemTaoQuanquan(itemId, title, mall = "taobao"){
  979. // console.log("fetchItemTaoQuanquan-----", itemId, title, mall);
  980. return new Promise((resolve, reject) => {
  981. if(!itemId && !title){
  982. reject(true);
  983. }
  984. const timestamp = new Date().getTime()+"";
  985. const biz = {mall, timestamp}
  986. let reqPath = "/queryCoupon";
  987. let param = itemId;
  988. if(itemId){
  989. biz.itemId = itemId;
  990. }else{
  991. biz.title = title;
  992. reqPath = "/querySearchList"
  993. param = encodeURI(title);
  994. // console.log("fetchItemTaoQuanquan--sign-before-biz---", biz)
  995. }
  996. const sign = generateSign(param, timestamp)
  997. // console.log("fetchItemTaoQuanquan--sign-after----", sign)
  998. biz.sign = sign;
  999. const postData = {biz};
  1000. fetch(`https://api.staybrowser.com/tqq/product${reqPath}`, {
  1001. method: 'POST',
  1002. headers: {
  1003. 'Content-Type': 'application/json'
  1004. },
  1005. body: JSON.stringify(postData)
  1006. })
  1007. .then(response => {
  1008. if (!response.ok) {
  1009. reject('Network response was not ok ' + response.statusText)
  1010. throw new Error('Network response was not ok ' + response.statusText);
  1011. }
  1012. return response.json(); // 将响应转换为 JSON
  1013. })
  1014. .then(data => {
  1015. // console.log("fetchItemTaoQuanquan---1-resp-------", data)
  1016. if(data){
  1017. // console.log("fetchItemTaoQuanquan-2-resp-----", data)
  1018. resolve(data)
  1019. }else{
  1020. // console.log("fetchItemTaoQuanquan--fetch error-------", result);
  1021. resolve({})
  1022. }
  1023. })
  1024. .catch((error) => {
  1025. console.error('Error:', error); // 处理错误
  1026. reject(true);
  1027. });
  1028. })
  1029. }
  1030.  
  1031. function sendLogEvent(type, data){
  1032. const biz = {
  1033. uuid: TaoQQUtils.getUserDeviceId(),
  1034. type,
  1035. data
  1036. }
  1037. fetch(`https://api.staybrowser.com/tqq/log/sendLog`, {
  1038. method: 'POST',
  1039. headers: {
  1040. 'Content-Type': 'application/json'
  1041. },
  1042. body: JSON.stringify({biz})
  1043. })
  1044. .then(response => {
  1045. if (!response.ok) {
  1046. throw new Error('Network response was not ok ' + response.statusText);
  1047. }
  1048. return response.json(); // 将响应转换为 JSON
  1049. })
  1050. .then(data => {
  1051. // console.log("sendLogEvent----resp-------", data)
  1052. })
  1053. .catch((error) => {
  1054. console.error('Error:', error); // 处理错误
  1055. });
  1056. }
  1057. (function({pageType, switchOff}){
  1058. // if(switchOff){
  1059. // return;
  1060. // }
  1061. const itemResMap = new Map();
  1062. switch(pageType){
  1063. case "list_page":
  1064. handleListPage();
  1065. break;
  1066. case "detail_page":
  1067. handleDetailPage();
  1068. break;
  1069. case "quan_page":
  1070. handleQuanPage();
  1071. }
  1072.  
  1073. function generateQuanCornerToList(nodeItem){
  1074. let currentNode = nodeItem;
  1075. let boxClass = "";
  1076. if(TaoQQUtils.isMobile() && !TaoQQUtils.isMobileTbHome()){
  1077. currentNode = nodeItem.nextElementSibling;
  1078. boxClass = "s8t9a0i8y66-m-quan";
  1079. }else{
  1080. // boxClass = window.location.pathname.includes("/search") ? 's8t9a0i8y66-quan-lp3-box' : 's8t9a0i8y66-quan-lp0-box';
  1081. // currentNode = nodeItem.querySelector(".Wonderful--mask--1fwB7tp")
  1082. // if(!currentNode){
  1083. // currentNode = nodeItem.querySelector(".FloorModule--mask--26Ahf9Q")
  1084. // }
  1085. // if(!currentNode){
  1086. // currentNode = nodeItem.querySelector(".MainPic--mainPicWrapper--iv9Yv90")
  1087. // }
  1088. // if(!currentNode){
  1089. // currentNode = nodeItem.querySelector(".MainPic--mainPicWrapper--vKqzSkJ")
  1090. // }
  1091. // if(!currentNode){
  1092. // currentNode = nodeItem.querySelector(".img-wrapper")
  1093. // }
  1094.  
  1095. }
  1096. if(!currentNode){
  1097. // console.log("nodeItem-----", nodeItem)
  1098. return null;
  1099. }
  1100. const quanDom = [
  1101. `<div class='s8t9a0i8y66-quan-box ${boxClass}'>`,
  1102. loadingHtml(0.6),
  1103. "</div>"
  1104. ];
  1105. currentNode.appendChild(TaoQQUtils.parseToDOM(quanDom.join("")));
  1106. return currentNode.querySelector(".s8t9a0i8y66-quan-box");
  1107. }
  1108. function handleListPage(){
  1109. let searchList = [];
  1110. let insertIndex = -1;
  1111. const __goods_item_style = `
  1112. .s8t9a0i8y66-m-b{
  1113. margin-bottom: 2.6667vw;
  1114. }
  1115. .s8t9a0i8y66-item{
  1116. align-items: center;
  1117. color: #000;
  1118. display: block;
  1119. text-decoration: none;
  1120. width: 100%;
  1121. }
  1122. .s8t9a0i8y66-img-mask{
  1123. background-color: rgba(0, 0, 0, .02);
  1124. height: 100%;
  1125. position: absolute;
  1126. width: 100%;
  1127. }
  1128. .s8t9a0i8y66-img{
  1129. border-radius: 3.2vw;
  1130. width: 47.6vw;
  1131. min-height: 47.6vw;
  1132. object-fit: cover;
  1133. }
  1134. .s8t9a0i8y66-title-wrapper{
  1135. display: flex;
  1136. flex-direction: row;
  1137. margin: 1.6vw 0 0 1.6vw;
  1138. width: 95%;
  1139. }
  1140. .s8t9a0i8y66-title{
  1141. -webkit-line-clamp: 2;
  1142. -webkit-box-orient: vertical;
  1143. word-wrap: break-word;
  1144. display: -webkit-box;
  1145. font-size: 3.46667vw;
  1146. font-weight: 700;
  1147. line-height: 4.8vw;
  1148. overflow: hidden;
  1149. text-overflow: ellipsis;
  1150. vertical-align: middle;
  1151. width: 100%;
  1152. word-break: break-all;
  1153. }
  1154. .s8t9a0i8y66-price-wrapper{
  1155. align-items: flex-end;
  1156. display: flex;
  1157. flex-direction: row;
  1158. margin: .66667vw 0 0 1.6vw;
  1159. width: 44.4vw;
  1160. }
  1161. .s8t9a0i8y66-price-unit{
  1162. color: #ff5000;
  1163. font-family: Alibaba-Sans102, PingFangSC-Medium;
  1164. font-size: 3.2vw;
  1165. font-weight: 700;
  1166. line-height: 3.73333vw;
  1167. }
  1168. .s8t9a0i8y66-price-int{
  1169. color: #ff5000;
  1170. font-family: Alibaba-Sans102, PingFangSC-Regular;
  1171. font-size: 5.6vw;
  1172. font-weight: 700;
  1173. line-height: 5.6vw;
  1174. margin-left: .66667vw;
  1175. }
  1176. .s8t9a0i8y66-price-float{
  1177. color: #ff5000;
  1178. font-family: Alibaba-Sans102, PingFangSC-Regular;
  1179. font-size: 4.26667vw;
  1180. font-weight: 700;
  1181. line-height: 4.53333vw;
  1182. }
  1183. .s8t9a0i8y66-price-sales{
  1184. color: #999;
  1185. font-family: PingFangSC-Regular;
  1186. font-size: 3.2vw;
  1187. line-height: 4.53333vw;
  1188. margin-left: 1.33333vw;
  1189. }
  1190. `;
  1191. GM_addStyle(__goods_item_style);
  1192. sendLogEvent("list_page", window.location.href);
  1193. function findABySelector(){
  1194. const itemDomList = Array.from(document.querySelectorAll(listPageAHref));
  1195. handleItemList(itemDomList);
  1196. }
  1197. function observeItemA(){
  1198. const MutationObserverSelf = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  1199. const mutationObserver = new MutationObserverSelf((mutations, observer) => {
  1200. mutations.map((function(record){
  1201. // console.log("record-----", record)
  1202. if(record.addedNodes){
  1203. for(let i=0;i<record.addedNodes.length;++i){
  1204. let addedItem = record.addedNodes.item(i);
  1205. // console.log("addedItem----", addedItem,addedItem.nodeName, addedItem.nodeType)
  1206. if(addedItem.nodeType !== Node.ELEMENT_NODE){
  1207. continue
  1208. }
  1209. let aNodes = addedItem.querySelectorAll(listPageAHref);
  1210. const aNodeList = Array.from(aNodes);
  1211. if(addedItem.nodeName.toUpperCase() === "A" && !addedItem.getAttribute("check-quan")){
  1212. aNodeList.push(addedItem);
  1213. }
  1214. handleItemList(aNodeList);
  1215. }
  1216. }
  1217. }))
  1218. });
  1219. mutationObserver.observe(document, {childList: true, subtree: true, attributes: true, attributeFilter: ['value']});
  1220. }
  1221.  
  1222.  
  1223. function handleInsertGoods(){
  1224. if(!searchList || searchList.length == 0 || insertIndex+1>=searchList.length){
  1225. return;
  1226. }
  1227. while(searchList.length>insertIndex){
  1228. insertIndex = insertIndex + 1;
  1229. const goodsItem = searchList[insertIndex];
  1230. let nth = 3 * Math.floor(insertIndex/2);
  1231. let parent = document.querySelector(".rax-scrollview-webcontainer .rax-view .rax-view:first-child");
  1232. if(insertIndex%2 == 1){
  1233. parent = document.querySelector(".rax-scrollview-webcontainer .rax-view .rax-view:last-child");
  1234. nth = 3 * Math.floor(insertIndex/2) + 2;
  1235. }
  1236. const nthChild = parent.children[nth];
  1237. if(!nthChild){
  1238. break;
  1239. }
  1240. let quanItem = "";
  1241. if(goodsItem.couponAmount && Number(goodsItem.couponAmount) > 0){
  1242. quanItem = `<div class='${TaoQQUtils.isMobile()&&!TaoQQUtils.isMobileTbHome()?'s8t9a0i8y66-m-quan-item':'s8t9a0i8y66-quan-item'}'>隐藏券<span class='s8t9a0i8y66-yuan'>¥</span><span class='s8t9a0i8y66-quan-amount'>${goodsItem.couponAmount}</span></div>`;
  1243. }
  1244. const newGoods = [
  1245. `<div class="rax-view-v2 s8t9a0i8y66-m-b" stay-goods="search">`,
  1246. `<div class="rax-view-v2">`,
  1247. `<a class="s8t9a0i8y66-item" check-quan="true" href=${goodsItem.itemUrl}>`,
  1248. `<div class="rax-view-v2" style="position:relative">`,
  1249. `<div class="rax-view-v2 s8t9a0i8y66-img-mask"></div>`,
  1250. `<img class="s8t9a0i8y66-img" src=${goodsItem.pictUrl} />`,
  1251. `</div>`,
  1252. `<div class="rax-view-v2 s8t9a0i8y66-title-wrapper"><div class="rax-view-v2 s8t9a0i8y66-title">${goodsItem.title}</div></div>`,
  1253. `<div class="rax-view-v2 s8t9a0i8y66-price-wrapper">`,
  1254. `<span class="rax-text-v2 s8t9a0i8y66-price-unit">¥</span>`,
  1255. `<span class="rax-text-v2 s8t9a0i8y66-price-int">${Math.floor(goodsItem.realPrice)}.</span>`,
  1256. `<span class="rax-text-v2 s8t9a0i8y66-price-float">${TaoQQUtils.computFloat(goodsItem.realPrice)}</span>`,
  1257. `<span class="rax-text-v2 s8t9a0i8y66-price-sales">${TaoQQUtils.computWan(goodsItem.volume)}人付款</span>`,
  1258. `</div>`,
  1259. `</a>`,
  1260. `<div class="rax-view-v2 SalesPoint--subIconWrapper--1MDy2Qt">`,
  1261. `<div class="rax-view-v2" style="background-color: rgb(255, 255, 255); border: 1px solid rgb(255, 168, 128); border-radius: 2px; display: flex; align-items: center; justify-content: center; margin-right: 0.8vw; margin-top: 0.5333vw; vertical-align: middle; line-height: 3.7333vw;"><span class="rax-text-v2 " style="color: rgb(255, 80, 0); font-size: 2.6667vw; padding: 0.2667vw 0.2667vw 0px;">包邮</span></div>`,
  1262. `<div class="rax-view-v2" style="background-color: rgb(255, 255, 255); border: 1px solid #E02020; border-radius: 2px; display: flex; align-items: center; justify-content: center; margin-right: 0.8vw; margin-top: 0.5333vw; vertical-align: middle; line-height: 3.7333vw;"><span class="rax-text-v2 " style="color: #E02020; font-size: 2.6667vw; padding: 0.2667vw 0.2667vw 0px;">淘补贴推荐</span></div>`,
  1263. `${quanItem}`,
  1264. `</div>`,
  1265. `<div class="rax-view-v2 ShopInfo--shopInfo--15nm1iL"><div class="rax-view-v2 ShopInfo--TextAndPic--1Io1UAy"><span style="font-size: 2.9333vw; line-height: 4.4vw; color: rgb(102, 102, 102); flex-shrink: 0; margin-right: 1.3333vw; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;">${goodsItem.shopTitle}</span><span style="font-size: 2.9333vw; line-height: 4.4vw; color: rgb(51, 51, 51); flex-shrink: 1; margin-right: 0vw; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;">进店</span></div><img class="rax-image ShopInfo--shopInfoPic--PqOWXdF" quality="high" autoscaling="false" resizemode="cover" data-once="true" src="//gw.alicdn.com/imgextra/i4/O1CN01y5K1Tu1bAhGJTfw8e_!!6000000003425-2-tps-12-24.png_.webp" style="width: 1.0667vw; height: 2.1333vw; object-fit: cover;"></div>`,
  1266. `</div>`,
  1267. `</div>`
  1268. ];
  1269. parent.insertBefore(TaoQQUtils.parseToDOM(newGoods.join("")), nthChild);
  1270. }
  1271. }
  1272.  
  1273. function searchTitle(title){
  1274. if(!title || title == ""){
  1275. return;
  1276. }
  1277. console.log("searchTitle-----title----", title);
  1278. // title = encodeURI(title);
  1279. insertIndex = -1;
  1280. fetchItemTaoQuanquan("", title, "taobao").then(res => {
  1281. console.log("searchTitle---res-", title, res);
  1282. const { server : {message} = {}, biz: { materialItemList } = {} } = res;
  1283. searchList = materialItemList;
  1284. handleInsertGoods();
  1285. }).catch(err => {
  1286. console.log("searchTitle---err-", err)
  1287. })
  1288. }
  1289.  
  1290. function delay(ms) {
  1291. return new Promise(resolve => setTimeout(resolve, ms));
  1292. }
  1293.  
  1294. async function processItemsInBatches(itemList, limit) {
  1295. const batches = [];
  1296. for (let i = 0; i < itemList.length; i += limit) {
  1297. const batch = itemList.slice(i, i + limit);
  1298. batches.push(batch);
  1299. }
  1300.  
  1301. for (const batch of batches) {
  1302. await Promise.all(batch.map(item => toCheckQuan(item)));
  1303. await delay(1000); // 等待1秒
  1304. }
  1305. }
  1306.  
  1307. function handleItemList(itemList = []){
  1308. processItemsInBatches(itemList, 5)
  1309. }
  1310.  
  1311. function toCheckQuan(nodeItem){
  1312. return new Promise((resolve, reject) => {
  1313. nodeItem.setAttribute('check-quan', "true");
  1314. const hrefUrl = nodeItem.getAttribute("href");
  1315. if(!hrefUrl){
  1316. resolve(true)
  1317. return;
  1318. }
  1319. if(TaoQQUtils.isMobileTbHome() && nodeItem.classList && nodeItem.classList.contains("recommend-info")){
  1320. resolve(true)
  1321. return;
  1322. }
  1323. let itemId = TaoQQUtils.queryURLParams(hrefUrl, "id");
  1324. if(!itemId || itemId == ""){
  1325. const regex = /i(\d+)\.htm/;
  1326. const match = hrefUrl.match(regex);
  1327. if (match) {
  1328. itemId = match[1];
  1329. } else {
  1330. // console.log("No match found itemId.");
  1331. resolve(true)
  1332. return;
  1333. }
  1334. }
  1335. if(!itemId || itemId == ""){
  1336. resolve(true)
  1337. return;
  1338. }
  1339. const currentNode = generateQuanCornerToList(nodeItem);
  1340. fetchItemTaoQuanquan(itemId, "", "taobao").then(res => {
  1341. // console.log("toCheckQuan---res-", res)
  1342. let quanItem = "";
  1343. const { server : {message} = {}, biz: { coupon_amount, coupon_url, tljAmount } = {} } = res;
  1344. if(coupon_amount && Number(coupon_amount) > 0){
  1345. quanItem = `<div class='${TaoQQUtils.isMobile()&&!TaoQQUtils.isMobileTbHome()?'s8t9a0i8y66-m-quan-item':'s8t9a0i8y66-quan-item'}'>隐藏券<span class='s8t9a0i8y66-yuan'>¥</span><span class='s8t9a0i8y66-quan-amount'>${coupon_amount}</span></div>`;
  1346. }
  1347. if(tljAmount && Number(tljAmount) > 0){
  1348. if(quanItem && (!TaoQQUtils.isMobile() || TaoQQUtils.isMobileTbHome())){
  1349. quanItem = quanItem + `<span style="color: #fff;font-size: 16px;">+</span>`
  1350. }
  1351. quanItem = quanItem + `<div class='${TaoQQUtils.isMobile()&&!TaoQQUtils.isMobileTbHome()?'s8t9a0i8y66-m-quan-item':'s8t9a0i8y66-quan-item'}'>预估补贴<span class='s8t9a0i8y66-yuan'>¥</span><span class='s8t9a0i8y66-quan-amount'>${tljAmount}</span></div>`;
  1352. }
  1353. if(quanItem && (!TaoQQUtils.isMobile() || TaoQQUtils.isMobileTbHome())){
  1354. quanItem = `<div class="s8t9a0i8y66-quan-corner-box">${quanItem}</div>`
  1355. }
  1356. if(currentNode){
  1357. if(TaoQQUtils.isMobile() && !TaoQQUtils.isMobileTbHome()){
  1358. const parentNode = currentNode.parentNode;
  1359. currentNode.remove();
  1360. parentNode.appendChild(TaoQQUtils.parseToDOM(quanItem));
  1361. }else{
  1362. // corner 方式
  1363. currentNode.innerHTML = quanItem
  1364. }
  1365. }
  1366. resolve(true);
  1367. }).catch(err => {
  1368. // console.log("toCheckQuan---err-", err)
  1369. currentNode && (currentNode.innerHTML = "");
  1370. resolve(true)
  1371. })
  1372. })
  1373. }
  1374.  
  1375. function listenerSearchInput(inputDom){
  1376. if(inputDom){
  1377. searchTitle(inputDom.value);
  1378. inputDom.addEventListener('change', (event) => {
  1379. let searchTimer = setTimeout(()=>{
  1380. console.log('Input value changed 2 to:', event.target.value, inputDom.value);
  1381. searchTitle(inputDom.value);
  1382. clearTimeout(searchTimer);
  1383. }, 200)
  1384. });
  1385. }
  1386. }
  1387.  
  1388. function startFindAItem(){
  1389. findABySelector();
  1390. observeItemA();
  1391. }
  1392.  
  1393. startFindAItem();
  1394.  
  1395. }
  1396.  
  1397. function handleDetailPage(){
  1398. if(window.top != window.self){
  1399. // console.log("handleDetailPage------top!=self")
  1400. // console.log('iframe--window-url-:', window.location.href);
  1401. window.addEventListener("message", (event)=>{
  1402. const action = event.data.action;
  1403. // console.log("---iframe----parent---window-----", event)
  1404. if(action === "checkout_goods_id"){
  1405. const itemSecretId = event.data.itemSecretId;
  1406. const index = event.data.index;
  1407. window.__stay_tb_item_secret_id = itemSecretId;
  1408. window.__stay_tb_item_index = index
  1409. // console.log("action----checkout_goods_id--itemSecretId-", itemSecretId);
  1410. window.top.postMessage({action: 'checkout_goods_id_res', url: window.location.href, index, itemSecretId}, "*");
  1411. }else if(action === "get_coupon"){
  1412. window.top.postMessage({action: 'get_coupon_res', url: window.location.href, id: event.data.id}, "*");
  1413. }
  1414. })
  1415. return;
  1416. }
  1417.  
  1418.  
  1419. //for detail
  1420. let quanItem = "";
  1421. let showModalSource = "";
  1422. let quanItemsMark = null;
  1423. let quanModalDom = null;
  1424. let showCouponModal = false;
  1425. const DETAIl_PAGE = {
  1426. title: "淘补贴",
  1427. couponUrl: "",
  1428. shouldReplace: false,
  1429. couponAmount: "",
  1430. loading: true,
  1431. tljLoading: true,
  1432. tljAmount: "",
  1433. confirmTljAmount: "",
  1434. }
  1435. const itemId = TaoQQUtils.queryURLParams(window.location.href, "id");
  1436. // console.log("handleDetailPage----itemId----", itemId);
  1437. sendLogEvent("detail_page", `{itemId:${itemId}}`);
  1438. function addQuanItemAction(){
  1439. quanItemsMark && quanItemsMark.addEventListener("click", generateTLJAndShowCouponModalEvent)
  1440. }
  1441.  
  1442. function removeQuanItemAction(){
  1443. quanItemsMark && quanItemsMark.removeEventListener("click", generateTLJAndShowCouponModalEvent)
  1444. }
  1445.  
  1446. function appendQuanDom(){
  1447. quanItemsMark = document.querySelector(".s8t9a0i8y66-quan-box");
  1448. if(quanItemsMark){
  1449. return quanItemsMark;
  1450. }
  1451. let currentNode = null;
  1452. let boxClass = "s8t9a0i8y66-detail-m-quan";
  1453. let nthChild = null
  1454. if(TaoQQUtils.isMobile()){
  1455. boxClass = "s8t9a0i8y66-detail-m-quan";
  1456. currentNode = document.querySelector("#scrollViewContainer .rax-scrollview-webcontainer .card-first");
  1457. if(!currentNode){
  1458. currentNode = document.querySelector("#detailCardFirst");
  1459. if(currentNode){
  1460. boxClass = boxClass + " s8t9a0i8y66-m-awp"
  1461. nthChild = currentNode.children[1];
  1462. }else{
  1463. currentNode = document.querySelector("div");
  1464. nthChild = currentNode[0];
  1465. boxClass = boxClass + " s8t9a0i8y66-detail-m-fixed";
  1466. }
  1467. }else{
  1468. nthChild = currentNode.children[1];
  1469. }
  1470. }else{
  1471. boxClass = "s8t9a0i8y66-detail-p-quan";
  1472. currentNode = document.querySelector("#purchasePanel .PurchasePanel--contentWrap--3APbL7v");
  1473. if(currentNode){
  1474. nthChild = currentNode.children[2];
  1475. }else{
  1476. currentNode = document.querySelector(".Item--content--12o-RdR .BasicContent--itemInfo--2NdSOrj .Price--root--1CrVGjc");
  1477. if(currentNode){
  1478. nthChild = currentNode.children[0];
  1479. }else{
  1480. currentNode = document.querySelector(".Item--content--12o-RdR .BasicContent--itemInfo--2NdSOrj .PromotionNew--promotionNew--2NhXfsn");
  1481. if(currentNode){
  1482. nthChild = currentNode.children[0];
  1483. }else{
  1484. currentNode = Array.from(document.querySelectorAll(".contentWrap--eIMKdlQ7")).find(element => {
  1485. const style = getComputedStyle(element);
  1486. return style.display !== 'none' && style.visibility !== 'hidden' && style.opacity !== '0';
  1487. });
  1488. if(currentNode){
  1489. nthChild = currentNode.children[2];
  1490. }
  1491. }
  1492. }
  1493. }
  1494. if(!currentNode){
  1495.  
  1496. currentNode = document.querySelector("#ice-container .pageContentWrap");
  1497. if(currentNode){
  1498. currentNode.style.position = "relative";
  1499. nthChild = currentNode.querySelectorAll("div")[0];
  1500. boxClass = boxClass + " s8t9a0i8y66-detail-pc-abs";
  1501. }else{
  1502. currentNode = document.querySelector("div");
  1503. nthChild = currentNode[0];
  1504. boxClass = boxClass + " s8t9a0i8y66-detail-pc-fixed";
  1505. }
  1506. }
  1507. }
  1508. const quanDom = [
  1509. `<div class='s8t9a0i8y66-quan-box ${boxClass}'>`,
  1510. loadingHtml(0.6),
  1511. "</div>"
  1512. ];
  1513. currentNode.insertBefore(TaoQQUtils.parseToDOM(quanDom.join("")), nthChild);
  1514. quanItemsMark = currentNode.querySelector(".s8t9a0i8y66-quan-box");
  1515. addQuanItemAction();
  1516. return quanItemsMark;
  1517. }
  1518.  
  1519. function addActionMaskDom(){
  1520. let actionOriginDom = null;
  1521. let actionClass = "";
  1522. if(TaoQQUtils.isIpad()){
  1523. return;
  1524. }
  1525. if(TaoQQUtils.isMobile()){
  1526. actionOriginDom = document.querySelector(".bottombar-inner .bottombarRight .bottombarRight");
  1527. actionClass = "s8t9a0i8y66-m-action"
  1528. if(!actionOriginDom){
  1529. actionClass = "";
  1530. actionOriginDom = document.querySelector("#bottomBarSection div[view-name='FrameLayout'] div[view-name='LinearLayout'] div[view-name='LinearLayout'] div[view-name='FrameLayout'] .dx-event-node[aria-label*='请用手机']");
  1531. }
  1532. if(!actionOriginDom){
  1533. // console.log("actionOriginDom-----null----")
  1534. actionClass = ""
  1535. actionOriginDom = document.querySelector("#h5Detail #bottomBar #bottomBarSection > div > div > div > div:nth-child(2) > div > div:nth-child(2)");
  1536. // actionOriginDom = document.querySelector("#bottomBarSection div[view-name='FrameLayout'] div[view-name='LinearLayout'] div[view-name='FrameLayout'] div[view-name='LinearLayout']")
  1537. }
  1538. return;
  1539. }else{
  1540. actionOriginDom = document.querySelector(".PurchasePanel--footWrap--3w0gUyF .Actions--root--uNUWMGB .Actions--leftButtons--2fasaTH");
  1541. if(!actionOriginDom){
  1542. actionOriginDom = document.querySelector("#root .Actions--root--hwEujgc .Actions--leftButtons--1M3KkF7");
  1543. }
  1544. actionClass = "s8t9a0i8y66-p-action"
  1545. }
  1546.  
  1547. if(!actionOriginDom){
  1548. // console.log("actionOriginDom-----null----not append-----")
  1549. return ;
  1550. }
  1551. let actionDom = [
  1552. `<div class="s8t9a0i8y66-bottom-action ${actionClass}" quan-modal="hidden">`,
  1553. `<div class='s8t9a0i8y66-joincar s8t9a0i8y66-action-item' type="joincar">`,
  1554. `<div class="s8t9a0i8y66-label10 s8t9a0i8y66-l-12">领券¥<span class="s8t9a0i8y66-label">${DETAIl_PAGE.couponAmount}</span></div>`,
  1555. `<div class="s8t9a0i8y66-label">加入购物车</div>`,
  1556. "</div>",
  1557. `<div class='s8t9a0i8y66-bynow s8t9a0i8y66-action-item' type="bynow">`,
  1558. `<div class="s8t9a0i8y66-label10 s8t9a0i8y66-l-3">领券¥<span class="s8t9a0i8y66-label">${DETAIl_PAGE.couponAmount}</span></div>`,
  1559. `<div class="s8t9a0i8y66-label">立即购买</div>`,
  1560. "</div>",
  1561. "</div>"
  1562. ];
  1563. // console.log("actionOriginDom-------", actionOriginDom, actionDom)
  1564. if(!(actionOriginDom.style.position) && !window.getComputedStyle(actionOriginDom).position){
  1565. actionOriginDom.style.position = "relative";
  1566. }
  1567. actionOriginDom.appendChild(TaoQQUtils.parseToDOM(actionDom.join("")));
  1568. addCarBuyActionEvent();
  1569. }
  1570.  
  1571. function handleTbopenSchema(){
  1572. if(DETAIl_PAGE.tljLoading){
  1573. showToast("补贴正在确认中...");
  1574. return;
  1575. }else{
  1576. // console.log("handleTbopenSchema----DETAIl_PAGE---", DETAIl_PAGE)
  1577. if(DETAIl_PAGE.couponUrl){
  1578. let openUrl = "";
  1579. if(window.__staytorn){
  1580. openUrl = `${DETAIl_PAGE.couponUrl.replace(/^https?:\/\//g, "taobao://")}&stayWebpageClick=true`;
  1581. }else{
  1582. openUrl = DETAIl_PAGE.couponUrl.replace(/^https?:\/\//g, "tbopen://");
  1583. }
  1584. let targetGun = document.createElement('a');
  1585. targetGun.rel="noopener noreferrer";
  1586. targetGun.href = openUrl;
  1587. targetGun.click();
  1588. }
  1589. }
  1590. }
  1591.  
  1592. function generateTLJAndShowCouponModalEvent(event){
  1593. event.stopPropagation();
  1594. if(DETAIl_PAGE.loading){
  1595. showToast("淘补贴正在确认中...");
  1596. return;
  1597. }
  1598. if(DETAIl_PAGE.itemSecretId){
  1599. if(!DETAIl_PAGE.confirmTljAmount){
  1600. queryTLJByItemId(getShopname(), DETAIl_PAGE.itemSecretId, getLowerPrice()).then(res=>{
  1601. const { server : {message} = {}, biz: { amount, sendUrl } = {} } = res;
  1602. // console.log("queryTLJByItemId---res-", res)
  1603. if(amount){
  1604. DETAIl_PAGE.tljAmount = amount
  1605. DETAIl_PAGE.confirmTljAmount = amount
  1606. }
  1607. if(sendUrl){
  1608. if(sendUrl != DETAIl_PAGE.couponUrl){
  1609. DETAIl_PAGE.shouldReplace = DETAIl_PAGE.couponUrl != sendUrl ? true: false;
  1610. }
  1611. DETAIl_PAGE.couponUrl = sendUrl;
  1612. }
  1613. updateTljAmount();
  1614. createCouponIframeIntoModal();
  1615. showQuanModal(event);
  1616. }).catch(err=>{
  1617. console.log("queryTLJByItemId---err-", err)
  1618. handleTljLoadingAndRemoveQuanItem();
  1619. showToast("淘补贴弄丢了~")
  1620. hiddenLoadingPannel();
  1621. })
  1622. }else{
  1623. showQuanModal(event);
  1624. }
  1625. }else{
  1626. DETAIl_PAGE.tljLoading = false;
  1627. showQuanModal(event);
  1628. }
  1629. }
  1630.  
  1631.  
  1632. function addCarBuyActionEvent(){
  1633. document.querySelector(".s8t9a0i8y66-bottom-action") && document.querySelector(".s8t9a0i8y66-bottom-action").addEventListener("click", generateTLJAndShowCouponModalEvent)
  1634. }
  1635.  
  1636. function removeCarBuyActionEvent(){
  1637. document.querySelector(".s8t9a0i8y66-bottom-action") && document.querySelector(".s8t9a0i8y66-bottom-action").removeEventListener("click", generateTLJAndShowCouponModalEvent)
  1638. }
  1639.  
  1640. /**
  1641. * @param {Number} targetX
  1642. * @param {Number} targetY
  1643. * @param {Number} targetWidth
  1644. * @param {Number} targetHeight
  1645. * @returns
  1646. */
  1647. function calcPolygonPoints(targetX, targetY, targetWidth, targetHeight){
  1648. targetX = Math.floor(targetX);
  1649. targetY = Math.floor(targetY) + 40;
  1650. targetWidth = Math.ceil(targetWidth);
  1651. targetHeight = Math.ceil(targetHeight);
  1652. // targetHeight = TaoQQUtils.sub(targetHeight, TaoQQUtils.mul(borderSize, 2));
  1653. let rectRightPointX = targetX + targetWidth;
  1654. let rectBottomPointY = targetY + targetHeight;
  1655. let polygon = `polygon(0 0, 0 ${targetY}px, ${targetX}px ${targetY}px, ${rectRightPointX}px ${targetY}px, ${rectRightPointX}px ${rectBottomPointY}px, ${targetX}px ${rectBottomPointY}px, ${targetX}px ${targetY}px, 0 ${targetY}px, 0 100%,100% 100%, 100% 0)`;
  1656. return polygon;
  1657. }
  1658.  
  1659. function showQuanModal(event){
  1660. // bottom click
  1661. showModalSource = "carbuy";
  1662. let quanModal = event && event.target? event.target.closest('.s8t9a0i8y66-bottom-action') : "";
  1663. if(!quanModal){
  1664. // quan click
  1665. quanModal = event && event.target?event.target.closest('.s8t9a0i8y66-quan-box') : "";
  1666. showModalSource = "quanitem";
  1667. }
  1668. if(TaoQQUtils.isMobile() || TaoQQUtils.isIpad()){
  1669. handleTbopenSchema();
  1670. return;
  1671. }
  1672. if(quanModal && quanModal.getAttribute("quan-modal") == "show"){
  1673. return;
  1674. }
  1675. quanModal && quanModal.setAttribute("quan-modal", "show");
  1676.  
  1677. quanModalDom = checkModalAndCreate();
  1678. quanModalDom.style.display = "block";
  1679. document.body.style.overflow = "hidden"
  1680. showCouponModal = true;
  1681. window.addEventListener("message", (event)=>{
  1682. const action = event.data.action;
  1683. if(action === "iframeLoaded"){
  1684. quanModalDom.setAttribute("quan-loaded", "true");
  1685. quanModalDom.querySelector(".s8t9a0i8y66-quan-mask").innerHTML = "";
  1686. quanModalDom.querySelector(".s8t9a0i8y66-quan-mask").style.display = "none";
  1687. //
  1688. const react = event.data.react;
  1689. // quanModalDom.querySelector(".s8t9a0i8y66-quan-mask").style.clipPath = calcPolygonPoints(react.left, react.top, react.width, react.height);
  1690. }
  1691. else if(action == "login"){
  1692. handleCloseModalEvent();
  1693. window.location.href = event.data.jump;
  1694. }
  1695. })
  1696. }
  1697.  
  1698. function removeCarBuyDom(){
  1699. removeCarBuyActionEvent();
  1700. document.querySelector(".s8t9a0i8y66-bottom-action") && document.querySelector(".s8t9a0i8y66-bottom-action").remove();
  1701. }
  1702.  
  1703. function handleCloseModalEvent(event){
  1704. document.body.style.overflow = "";
  1705. if(event){
  1706. showModalSource = event.target.getAttribute("click-source");
  1707. }
  1708. if(quanModalDom){
  1709. quanModalDom.style.display = "none";
  1710. showCouponModal = false;
  1711. if("carbuy" == showModalSource){
  1712. document.querySelector(".s8t9a0i8y66-bottom-action") && document.querySelector(".s8t9a0i8y66-bottom-action").setAttribute("quan-modal", "hidden");
  1713. removeCarBuyDom();
  1714. }else{
  1715. quanItemsMark && quanItemsMark.setAttribute("quan-modal", "hidden");
  1716. }
  1717. }
  1718. }
  1719.  
  1720. function createCouponIframeIntoModal(){
  1721. if(!quanModalDom){
  1722. return;
  1723. }
  1724. if(quanModalDom){
  1725. let couponIframeDom = quanModalDom.querySelector(".s8t9a0i8y66-quan-frame");
  1726. if(!couponIframeDom){
  1727. couponIframeDom = document.createElement("iframe");
  1728. couponIframeDom.src = DETAIl_PAGE.couponUrl;
  1729. couponIframeDom.width = 320;
  1730. couponIframeDom.height = 540;
  1731. couponIframeDom.sandbox="allow-same-origin allow-scripts";
  1732. couponIframeDom.classList.add("s8t9a0i8y66-quan-frame");
  1733. // TaoQQUtils.parseToDOM(`<iframe class="s8t9a0i8y66-quan-frame" width=320 height=600 src=${DETAIl_PAGE.couponUrl}></iframe>`)
  1734. quanModalDom.querySelector(".s8t9a0i8y66-quan-modal") && quanModalDom.querySelector(".s8t9a0i8y66-quan-modal").appendChild(couponIframeDom)
  1735. }else{
  1736. if(DETAIl_PAGE.shouldReplace){
  1737. couponIframeDom.src = DETAIl_PAGE.couponUrl;
  1738. }
  1739. const loadingMask = quanModalDom.querySelector(".s8t9a0i8y66-quan-mask");
  1740. if(loadingMask){
  1741. quanModalDom.querySelector(".s8t9a0i8y66-quan-mask").remove();
  1742. }
  1743. }
  1744. addListenerCouponModalToClose(couponIframeDom);
  1745. }
  1746. }
  1747.  
  1748. function addListenerCouponModalToClose(couponIframeDom){
  1749. couponIframeDom = couponIframeDom || quanModalDom.querySelector(".s8t9a0i8y66-quan-frame");
  1750. if(!couponIframeDom){
  1751. return;
  1752. }
  1753. const id = TaoQQUtils.generateUuid();
  1754. couponIframeDom.onload = function() {
  1755. couponIframeDom.contentWindow.postMessage({action: 'get_coupon', id}, "*");
  1756. const callback = e => {
  1757. // console.log("get_coupon_res---addEventListener-----", e)
  1758. if (e.data.id !== id || e.data.action !== 'get_coupon_res') return;
  1759. showModalSource = "carbuy";
  1760. handleCloseModalEvent();
  1761. window.removeEventListener('message', callback);
  1762. }
  1763. window.addEventListener("message", callback);
  1764. }
  1765. }
  1766.  
  1767. function checkModalAndCreate(){
  1768. let quanModalDom = document.querySelector(".s8t9a0i8y66-quan-modal-box")
  1769. if(!quanModalDom){
  1770. // console.log("checkModalAndCreate----no--quanModalDom-")
  1771. const quanModalHtml = [
  1772. '<div class="s8t9a0i8y66-quan-modal-box">',
  1773. '<div class="s8t9a0i8y66-quan-modal">',
  1774. `<div class="s8t9a0i8y66-quan-modal-title">${DETAIl_PAGE.title}</div>`,
  1775. `<div class="s8t9a0i8y66-quan-close-con" click-source="${showModalSource}"></div>`,
  1776. `<div class="s8t9a0i8y66-quan-mask">${loadingHtml(1)}</div>`,
  1777. DETAIl_PAGE.tljLoading?"":`<iframe class="s8t9a0i8y66-quan-frame" sandbox="allow-same-origin allow-scripts" width=320 height=540 src=${DETAIl_PAGE.couponUrl}></iframe>`,
  1778. "</div>",
  1779. "</div>"
  1780. ];
  1781. document.body.appendChild(TaoQQUtils.parseToDOM(quanModalHtml.join("")));
  1782. quanModalDom = document.querySelector(".s8t9a0i8y66-quan-modal-box");
  1783. quanModalDom.querySelector(".s8t9a0i8y66-quan-close-con").addEventListener("click", handleCloseModalEvent);
  1784. createCouponIframeIntoModal();
  1785. }else{
  1786. quanModalDom.querySelector(".s8t9a0i8y66-quan-close-con").setAttribute("click-source", showModalSource);
  1787. }
  1788. // console.log("checkModalAndCreate------quanModalDom-", quanModalDom)
  1789. return quanModalDom;
  1790. }
  1791. function getLowerPrice(){
  1792. try {
  1793. // pc1
  1794. let priceDom = document.querySelector(".Price--root--1X-r-XP .Price--priceWrap--3MY0wsh");
  1795. if(!priceDom){
  1796. priceDom = document.querySelector(".card-first .wrap-container");
  1797. }
  1798. if(!priceDom){
  1799. priceDom = document.querySelector("#priceSection .tpl-wrapper");
  1800. }
  1801. if(!priceDom){
  1802. priceDom = document.querySelector("#priceBeltSection");
  1803. }
  1804. if(!priceDom){
  1805. priceDom = document.querySelector(".Price--root--1CrVGjc");
  1806. }
  1807. if(!priceDom){
  1808. priceDom = document.querySelector("#ice-container .title_container--YFUwL6hx");
  1809. }
  1810. if(!priceDom){
  1811. priceDom = document.querySelector(".summaryInfoWrap--Ndc7k4Hv .purchasePanel--cG3DU6bX");
  1812. }
  1813. let priceText = "";
  1814. if(priceDom){
  1815. priceText = priceDom.textContent?priceDom.textContent.replace(/隐藏券¥\d+(\.\d{1,2})?/g, '').replace(/预估补贴¥\d+(\.\d{1,2})?/g, '').replace(/点击领取补贴¥\d+(\.\d{1,2})?/g, '').replace(/\s+/g, '').replace(/[¥¥]/g, '¥') : "";
  1816. }
  1817. if(priceText){
  1818. const arr = priceText.match(/¥\d+(\.\d{1,2})?/g);
  1819. if(arr && arr.length){
  1820. var amounts = arr.map(value => parseFloat(value.replace(/[¥¥]/g, '')));
  1821. return Math.min(...amounts);
  1822. }
  1823. }
  1824. } catch (error) {
  1825. console.error("get lower price error", error)
  1826. }
  1827. return "";
  1828. }
  1829.  
  1830. function getShopname(){
  1831. try {
  1832. let shopDom = document.querySelector(".pageContentWrap .ShopHeader--detailWrap--1zgrGb2 .ShopHeader--shopName--zZ3913d");
  1833. if(!shopDom){
  1834. shopDom = document.querySelector("#detailHome #storeCardSection > div > div > div > div:nth-child(3) > div:nth-child(2) > span");
  1835. }
  1836. if(!shopDom){
  1837. shopDom = document.querySelector(".card-sixth .shop-card .rax-view-v2 span");
  1838. }
  1839. if(!shopDom){
  1840. shopDom = document.querySelector(".SearchHeader--content--1TWLzdT .SearchHeader--logo--3MwMa7A");
  1841. if(!shopDom){
  1842. shopDom = document.querySelector(".rax-scrollview-webcontainer .market-card-wrap .market-task-wrap");
  1843. }
  1844. if(shopDom){
  1845. return "天猫超市";
  1846. }
  1847. }
  1848. if(!shopDom){
  1849. // 底部联系客服
  1850. shopDom = document.querySelector("#bottomBarSection > div > div > div > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > span");
  1851. if(!shopDom){
  1852. shopDom = document.querySelector("#root .bottombar .bottombarLeft .bottombarLeftItem .bottombarItemText");
  1853. }
  1854. if(shopDom && shopDom.textContent.indexOf("天猫超市") > -1){
  1855. return "天猫超市"
  1856. }
  1857. }
  1858. if(shopDom){
  1859. if(shopDom.textContent == "淘工厂" || shopDom.textContent == "店铺" || shopDom.textContent == "自营店"){
  1860. return "";
  1861. }
  1862. return shopDom.textContent;
  1863. }
  1864. } catch (error) {
  1865. }
  1866. }
  1867.  
  1868. function getTitle(){
  1869. try {
  1870. let titleDom = document.querySelector(".pageContentWrap #purchasePanel .ItemTitle--root--3V3R5Y_ h1") || document.querySelector(".purchasePanel--cG3DU6bX .ItemTitle--UReZzEW5 h1");;
  1871. if(!titleDom){
  1872. titleDom = document.querySelector("#detailHome #titleSection");
  1873. }
  1874. if(!titleDom){
  1875. titleDom = document.querySelector(".ItemHeader--root--DXhqHxP .ItemHeader--mainTitle--3CIjqW5");
  1876. }
  1877. if(!titleDom){
  1878. titleDom = document.querySelector("#scrollViewContainer > div > div.rax-view-v2.card-first .rax-view-v2 span.title")
  1879. }
  1880. if(titleDom){
  1881. return titleDom.textContent?titleDom.textContent.trim():"";
  1882. }
  1883. } catch (error) {
  1884. }
  1885. }
  1886.  
  1887. function fetchGoods(biz, path, userId){
  1888. // console.log("fetchGoods-----", biz, path);
  1889. return new Promise((resolve, reject) => {
  1890. if(!biz || Object.keys(biz).length == 0){
  1891. reject(true);
  1892. }
  1893. const postData = {biz};
  1894. if(userId){
  1895. postData.client = {userId: userId}
  1896. }
  1897. fetch(`https://api.staybrowser.com/tqq/product${path}`, {
  1898. method: 'POST',
  1899. headers: {
  1900. 'Content-Type': 'application/json'
  1901. },
  1902. body: JSON.stringify(postData)
  1903. })
  1904. .then(response => {
  1905. if (!response.ok) {
  1906. reject('Network response was not ok ' + response.statusText)
  1907. throw new Error('Network response was not ok ' + response.statusText);
  1908. }
  1909. return response.json(); // 将响应转换为 JSON
  1910. })
  1911. .then(data => {
  1912. // console.log("fetchGoods--path--",path,"---resp-------", data)
  1913. if(data){
  1914. resolve(data)
  1915. }else{
  1916. // console.log("fetchItemTaoQuanquan--fetch error-------", result);
  1917. resolve({})
  1918. }
  1919. })
  1920. .catch((error) => {
  1921. console.error('Error:', error); // 处理错误
  1922. reject(true);
  1923. });
  1924. })
  1925. }
  1926.  
  1927. function checkCSPMeta(){
  1928. const metaTags = document.getElementsByTagName('meta');
  1929. let cspExists = false;
  1930. for (let i = 0; i < metaTags.length; i++) {
  1931. if (metaTags[i].httpEquiv === "Content-Security-Policy" &&
  1932. metaTags[i].content === "upgrade-insecure-requests") {
  1933. cspExists = true;
  1934. break;
  1935. }
  1936. }
  1937. return cspExists;
  1938. }
  1939. function createIframeToCheckGoods(itemSecretId, index, src){
  1940. if(!checkCSPMeta()){
  1941. const meta = document.createElement('meta');
  1942. meta.httpEquiv = "Content-Security-Policy";
  1943. meta.content = "upgrade-insecure-requests";
  1944. document.head.appendChild(meta)
  1945. }
  1946. let iframeDom = document.querySelector(`#Stay_${itemSecretId}`);
  1947. console.log("createIframeToCheckGoods-----iframeDom-------", iframeDom)
  1948. try {
  1949. if(!iframeDom){
  1950. const iframeDomStr = `<iframe id="Stay_${itemSecretId}" index=${index} width=320 height=540 style="display:none" src=${src}></iframe>`;
  1951. iframeDom = TaoQQUtils.parseToDOM(iframeDomStr);
  1952. iframeDom.onerror = function(e) {
  1953. console.error("Failed to load iframe content.", e);
  1954. throw new Error('failed_to_load_iframe');
  1955. };
  1956. document.body.appendChild(iframeDom);
  1957. iframeDom = document.querySelector(`#Stay_${itemSecretId}`);
  1958. }
  1959. } catch (error) {
  1960. console.log("createIframeToCheckGoods----error---", error, iframeDom)
  1961. }
  1962. return iframeDom;
  1963. }
  1964.  
  1965. async function hitGoodsItem(materialItemList){
  1966. if(!materialItemList || materialItemList.length == 0){
  1967. return null;
  1968. }
  1969. const results = await Promise.all(materialItemList.map(async (item, index) => {
  1970. console.log("hitGoodsId-----itemId----", itemId)
  1971. const goodsId = await loadIframeToGainGoodsId(item.itemId, index, item.originUrl);
  1972. console.log("hitGoodsId----goodsId-----",goodsId)
  1973. if(!goodsId){
  1974. return null;
  1975. }
  1976. if(goodsId == itemId){
  1977. return item;
  1978. }
  1979. return null;
  1980. }));
  1981. const firstMatch = results.find(item => item !== null);
  1982. return firstMatch || null;
  1983. }
  1984.  
  1985. function checkGoods(materialItemList){
  1986. if(!materialItemList || materialItemList.length == 0){
  1987. handleTljLoadingAndRemoveQuanItem();
  1988. return;
  1989. }
  1990. hitGoodsItem(materialItemList).then(item => {
  1991. // console.log("hitGoodsItem----res-----", item);
  1992. if(item){
  1993. DETAIl_PAGE.itemSecretId = item.itemId;
  1994. if(typeof item.tljAmount == "undefined" || !item.tljAmount || item.tljAmount == ""){
  1995. // console.log("checkGoods----goodsId---item.tljAmount--is-not", goodsId, item.tljAmount)
  1996. if(item.couponShareUrl){
  1997. DETAIl_PAGE.shouldReplace = DETAIl_PAGE.couponUrl != item.couponShareUrl? true: false;
  1998. DETAIl_PAGE.couponUrl = item.couponShareUrl;
  1999. DETAIl_PAGE.tljAmount = "";
  2000. }
  2001. handleTljLoadingAndRemoveQuanItem();
  2002. createCouponIframeIntoModal();
  2003. }else{
  2004. DETAIl_PAGE.tljAmount = item.tljAmount;
  2005. }
  2006. updateTljAmount();
  2007. }else{
  2008. handleTljLoadingAndRemoveQuanItem();
  2009. }
  2010. });
  2011. }
  2012.  
  2013. function handleGoodsIdByUrl(detailUrl){
  2014. if(!detailUrl){
  2015. return "";
  2016. }
  2017. let goodsId = TaoQQUtils.queryURLParams(detailUrl, "id");
  2018. if(goodsId){
  2019. return goodsId;
  2020. }
  2021. const redirectURL = TaoQQUtils.queryURLParams(detailUrl, "redirectURL");
  2022. if(!redirectURL){
  2023. return "";
  2024. }
  2025. const x5referer = TaoQQUtils.queryURLParams(redirectURL, "x5referer");
  2026. if(!x5referer){
  2027. return "";
  2028. }
  2029. goodsId = TaoQQUtils.queryURLParams(x5referer, "id");
  2030. return goodsId;
  2031. }
  2032.  
  2033. function loadIframeToGainGoodsId(itemSecretId, index, originUrl){
  2034. return new Promise((resolve, reject) => {
  2035. try {
  2036. const iframeDom = createIframeToCheckGoods(itemSecretId, index, originUrl);
  2037. if(!iframeDom){
  2038. resolve("");
  2039. return;
  2040. }
  2041. iframeDom.onload = function() {
  2042. console.log("loadIframeToGainGoodsId------iframeDom----", iframeDom)
  2043. iframeDom.contentWindow.postMessage({action: 'checkout_goods_id', itemSecretId, index}, "*");
  2044. const callback = e => {
  2045. console.log("checkout_goods_id_res---addEventListener-----", e)
  2046. if (e.data.itemSecretId !== itemSecretId || e.data.action !== 'checkout_goods_id_res') return;
  2047. window.removeEventListener('message', callback);
  2048. const checkoutGoodsId = handleGoodsIdByUrl(e.data.url);
  2049. console.log("checkoutGoodsId-----", checkoutGoodsId)
  2050. resolve(checkoutGoodsId);
  2051. }
  2052. window.addEventListener("message", callback);
  2053. };
  2054. } catch (error) {
  2055. console.error("load iframe to gain goods id have en error", error);
  2056. resolve("");
  2057. }
  2058. })
  2059. }
  2060.  
  2061. function updateTljAmount(){
  2062. removeLoading();
  2063. if(DETAIl_PAGE.tljAmount && Number(DETAIl_PAGE.tljAmount) > 0){
  2064. DETAIl_PAGE.title = "领取淘补贴"
  2065. if(quanItemsMark){
  2066. const tljQuanDom = quanItemsMark.querySelector("#s8t9a0i8y66_tlj .s8t9a0i8y66-tlj-text");
  2067. if(tljQuanDom){
  2068. tljQuanDom.innerHTML = "点击领取补贴";
  2069. }
  2070. const tljAmountDom = quanItemsMark.querySelector("#s8t9a0i8y66_tlj_amount");
  2071. if(tljAmountDom){
  2072. tljAmountDom.innerHTML = DETAIl_PAGE.confirmTljAmount || DETAIl_PAGE.tljAmount;
  2073. }
  2074. }
  2075. if(quanModalDom){
  2076. const modalTitleDom = quanModalDom.querySelector(".s8t9a0i8y66-quan-modal-title");
  2077. if(modalTitleDom){
  2078. modalTitleDom.innerHTML = DETAIl_PAGE.title;
  2079. }
  2080. }
  2081. }
  2082. }
  2083.  
  2084. function removeLoading(){
  2085. DETAIl_PAGE.tljLoading = false;
  2086. DETAIl_PAGE.loading = false;
  2087. if(quanItemsMark){
  2088. // console.log("handleTljLoadingAndRemoveQuanItem---quanItemsMark----", quanItemsMark.querySelector("#s8t9a0i8y66_tlj_confirm"))
  2089. quanItemsMark.querySelector("#s8t9a0i8y66_tlj_confirm")&&(quanItemsMark.querySelector("#s8t9a0i8y66_tlj_confirm").remove());
  2090. }else{
  2091. document.querySelector("#s8t9a0i8y66_tlj_confirm")&&(document.querySelector("#s8t9a0i8y66_tlj_confirm").remove());
  2092. }
  2093. hiddenLoadingPannel();
  2094. }
  2095.  
  2096. function handleTljLoadingAndRemoveQuanItem(){
  2097. removeLoading();
  2098. if(!quanItemsMark){
  2099. removeCarBuyDom();
  2100. return;
  2101. }
  2102. const tljQuanDom = quanItemsMark.querySelector("#s8t9a0i8y66_tlj");
  2103. const tqqDom = quanItemsMark.querySelector("#s8t9a0i8y66_tqq");
  2104. if(!DETAIl_PAGE.couponUrl){
  2105. removeQuanItemAction();
  2106. removeCarBuyDom();
  2107. if((DETAIl_PAGE.couponAmount)){
  2108. tqqDom && (tqqDom.innerHTML = "隐藏券丢失了")
  2109. }
  2110. if((DETAIl_PAGE.tljAmount)){
  2111. tljQuanDom && (tljQuanDom.innerHTML = "淘补贴已失效")
  2112. }
  2113. if((!DETAIl_PAGE.couponAmount || Number(DETAIl_PAGE.couponAmount) <= 0) && (!DETAIl_PAGE.tljAmount || Number(DETAIl_PAGE.tljAmount) <= 0)){
  2114. quanItemsMark.remove();
  2115. }
  2116. return;
  2117. }
  2118. if((!DETAIl_PAGE.couponAmount || Number(DETAIl_PAGE.couponAmount) <= 0)){
  2119. if(tqqDom){
  2120. tqqDom.remove();
  2121. }
  2122. }
  2123. // <div class='s8t9a0i8y66-detail-quan-item' id="s8t9a0i8y66_tlj"><span class="s8t9a0i8y66-tlj-text">预估补贴</span><span class="s8t9a0i8y66-yuan">¥</span><span class='s8t9a0i8y66-quan-amount' id="s8t9a0i8y66_tlj_amount">${tljAmount}</span></div>
  2124. if((!DETAIl_PAGE.tljAmount || Number(DETAIl_PAGE.tljAmount) <= 0)){
  2125. if(tljQuanDom){
  2126. tljQuanDom.remove();
  2127. }
  2128. }
  2129.  
  2130. }
  2131. function queryGoodsByTitle(shopName, title, mall = "taobao"){
  2132. // console.log("queryGoodsByTitle--shopName--title--------", shopName, title)
  2133. if(!title){
  2134. handleTljLoadingAndRemoveQuanItem();
  2135. return
  2136. }
  2137. DETAIl_PAGE.loading = true;
  2138. const timestamp = new Date().getTime()+"";
  2139. const biz = {mall, timestamp, shopName, title}
  2140. const param = encodeURI(title);
  2141. // console.log("title-encode----", param);
  2142. const sign = generateSign(param, timestamp)
  2143. biz.sign = sign;
  2144. fetchGoods(biz, "/queryGoodsByTitle").then(res => {
  2145. const { server : {message} = {}, biz: { materialItemList } = {} } = res;
  2146. // console.log("queryGoodsByTitle---res-", res)
  2147. checkGoods(materialItemList);
  2148. }).catch(err=>{
  2149. // console.log("queryGoodsByTitle---err-", err)
  2150. DETAIl_PAGE.loading=false;
  2151. handleTljLoadingAndRemoveQuanItem();
  2152. })
  2153. }
  2154.  
  2155. function queryTLJByItemId(shopName, itemId, price="", mall = "taobao"){
  2156. // console.log("queryTLJByItemId--shopName--itemId--------", shopName, itemId, price)
  2157. return new Promise((resolve, reject) => {
  2158. if(!itemId){
  2159. // console.log("queryTLJByItemId----itemId---is null-----", itemId)
  2160. DETAIl_PAGE.tljLoading=false;
  2161. reject("淘补贴失效了~")
  2162. return
  2163. }
  2164. showLoadingPannel("淘补贴生成中");
  2165. const timestamp = new Date().getTime()+"";
  2166. const biz = {mall, timestamp, shopName, itemId, price}
  2167. const param = encodeURI(itemId);
  2168. const sign = generateSign(param, timestamp)
  2169. biz.sign = sign;
  2170. fetchGoods(biz, "/queryTljCoupon", TaoQQUtils.getUserDeviceId()).then(res => {
  2171. resolve(res)
  2172. }).catch(err=>{
  2173. reject(err)
  2174. })
  2175. })
  2176. }
  2177.  
  2178. function createQuanAndAppend(){
  2179. return new Promise((resolve, reject) => {
  2180. if (document.readyState === 'complete') {
  2181. quanItemsMark = appendQuanDom();
  2182. // console.log("document.readyState--1----", document.readyState, quanItemsMark)
  2183. if(quanItemsMark){
  2184. resolve(true)
  2185. return;
  2186. }
  2187. }
  2188.  
  2189. document.addEventListener("readystatechange", ()=>{
  2190. if (document.readyState === 'complete') {
  2191. quanItemsMark = appendQuanDom();
  2192. // console.log("document.readyState--2----", document.readyState, quanItemsMark )
  2193. resolve(true)
  2194. }
  2195. });
  2196. })
  2197. }
  2198.  
  2199. function startCheckQuan(){
  2200. // console.log("startCheckQuan-----sttart-----itemId-", itemId)
  2201. fetchItemTaoQuanquan(itemId, "", "taobao").then(res => {
  2202. const { server : {message} = {}, biz: { coupon_amount, coupon_url, tljAmount } = {} } = res;
  2203.  
  2204. if((!coupon_amount || Number(coupon_amount) <= 0) && (!tljAmount || Number(tljAmount) <= 0)){
  2205. return;
  2206. }
  2207. if(Number(coupon_amount) > 0){
  2208. quanItem = `<div class='s8t9a0i8y66-detail-quan-item' id="s8t9a0i8y66_tqq">隐藏券<span class="s8t9a0i8y66-yuan">¥</span><span class='s8t9a0i8y66-quan-amount'>${coupon_amount}</span></div>`;
  2209. DETAIl_PAGE.couponAmount = coupon_amount;
  2210. }
  2211. DETAIl_PAGE.couponUrl = coupon_url;
  2212. if(Number(tljAmount) > 0){
  2213. quanItem = quanItem + `<div class='s8t9a0i8y66-detail-quan-item' id="s8t9a0i8y66_tlj"><span class="s8t9a0i8y66-tlj-text">预估补贴</span><span class="s8t9a0i8y66-yuan">¥</span><span class='s8t9a0i8y66-quan-amount' id="s8t9a0i8y66_tlj_amount">${tljAmount}</span><div id="s8t9a0i8y66_tlj_confirm" class="s8t9a0i8y66-tlj-confirm">确认中${loadingHtml(0.6, 'white')}</div></div>`;
  2214. DETAIl_PAGE.tljAmount = tljAmount;
  2215. }
  2216. DETAIl_PAGE.loading = true;
  2217. createQuanAndAppend().then(()=>{
  2218. // console.log("createQuanAndAppend---then----quanItemsMark--", quanItemsMark)
  2219. if(quanItemsMark){
  2220. quanItemsMark.innerHTML = quanItem;
  2221. addActionMaskDom()
  2222. // 确认淘补贴
  2223. queryGoodsByTitle(getShopname(), getTitle());
  2224. }
  2225. }).catch(err=>{
  2226. DETAIl_PAGE.loading = false;
  2227. // console.log("createQuanAndAppend----error----", err)
  2228. });
  2229. }).catch(err => {
  2230. // console.log("toCheckQuan---err-", err)
  2231. DETAIl_PAGE.loading = false;
  2232. })
  2233. }
  2234.  
  2235. startCheckQuan();
  2236. }
  2237.  
  2238. function handleQuanPage(){
  2239. // console.log("handleQuanPage----------")
  2240. document.addEventListener("readystatechange", ()=>{
  2241. if (document.readyState === 'complete') {
  2242. handleScrollToQuanView();
  2243. }
  2244. })
  2245. window.addEventListener('message', function(event) {
  2246. // console.log("quanframe--message---", event)
  2247. const action = event.data.action;
  2248.  
  2249. if (action === 'scrollToQuanView') {
  2250. // console.log("quanframe--scrollToQuanView---")
  2251. handleScrollToQuanView();
  2252. }
  2253. });
  2254.  
  2255. function handleScrollToQuanView(){
  2256. let couponDom = document.querySelector(".cellex-boom-mm-coupon-inventory-wrap");
  2257. let react = {};
  2258. if(!couponDom){
  2259. couponDom = document.querySelector(".cell-cellx-nocoupon-other-coupons-wrap");
  2260. }
  2261. if(!couponDom){
  2262. couponDom = document.querySelector(".cellx-2in1-many-coupon");
  2263. }
  2264. if(couponDom){
  2265. react = couponDom.getBoundingClientRect();
  2266. }
  2267. // console.log("handleScrollToQuanView--react---", react)
  2268. const screenH = 300;
  2269. if(react && typeof react.top === 'number' && typeof react.height === 'number'){
  2270. let scrollTop = 0;
  2271. if(react.height >= screenH){
  2272. scrollTop = Math.floor(react.top);
  2273. }else{
  2274. scrollTop = Math.floor(react.top) - (screenH - Math.ceil(react.height))/2;
  2275. }
  2276. // console.log("handleScrollToQuanView--scrollTop---", scrollTop);
  2277. window.scrollBy(0, scrollTop);
  2278. react = couponDom.getBoundingClientRect();
  2279. }
  2280. // console.log("handleScrollToQuanView--after--react---", react)
  2281. window.top.postMessage({action: 'iframeLoaded', react}, "*");
  2282. }
  2283.  
  2284. }
  2285.  
  2286. })({pageType: TaoQQUtils.checkPage(), switchOff})
  2287.  
  2288. })();

QingJ © 2025

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