twbuyer

twbuyer include shopping site

  1. // ==UserScript==
  2. // @name twbuyer
  3. // @namespace https://mesak.tw
  4. // @version 0.2
  5. // @description twbuyer include shopping site
  6. // @author Mesak
  7. // @match https://24h.pchome.com.tw/prod/*
  8. // @match https://shopping.pchome.com.tw/prod/*
  9. // @match https://www.momoshop.com.tw/goods/GoodsDetail.jsp*
  10. // @match https://tw.buy.yahoo.com/gdsale/gdsale.asp?gdid=*
  11. // @match https://shopping.udn.com/mall/cus/cat/Cc1c01.do?*
  12. // @license MIT
  13. // @grant GM_addStyle
  14. // ==/UserScript==
  15.  
  16. (function () {
  17. 'use strict';
  18.  
  19. let twb_main = document.createElement('div');
  20. let twb_modal = document.createElement('div');
  21. twb_modal.setAttribute('id', 'twb_modal');
  22. twb_modal.setAttribute('class', 'twb_modal');
  23. twb_modal.innerHTML = `<!-- The Modal -->
  24. <!-- Modal content -->
  25. <div class="twb_modal-content">
  26. <span class="twb_close">&times;</span>
  27. <div id="twb_content"></div>
  28. </div>`
  29. twb_main.appendChild(twb_modal);
  30.  
  31. let twb_nav_area = document.createElement('div');
  32. twb_nav_area.setAttribute('id', 'twb_nav_area');
  33. twb_nav_area.setAttribute('class', 'twb_sidenav');
  34. twb_nav_area.innerHTML = `<a href="#" id="twb_btn_twbuyer">歷史價</a>`;
  35.  
  36. twb_main.appendChild(twb_nav_area);
  37.  
  38. document.body.after(twb_main);
  39. GM_addStyle(`
  40. #twb_nav_area a {
  41. position: absolute; /* Position them relative to the browser window */
  42. left: -80px; /* Position them outside of the screen */
  43. transition: 0.3s; /* Add transition on hover */
  44. padding: 15px; /* 15px padding */
  45. width: 100px; /* Set a specific width */
  46. text-decoration: none; /* Remove underline */
  47. font-size: 20px; /* Increase font size */
  48. color: white; /* White text color */
  49. border-radius: 0 5px 5px 0; /* Rounded corners on the top right and bottom right side */
  50. z-index: 9998; /* Sit on top */
  51. }
  52. #twb_nav_area a:hover {
  53. left: 0; /* On mouse-over, make the elements appear as they should */
  54. }
  55. #twb_btn_twbuyer {
  56. top: 20px;
  57. background-color: #04AA6D;
  58. }
  59.  
  60. /* The Modal (background) */
  61. .twb_modal {
  62. display: none; /* Hidden by default */
  63. position: fixed; /* Stay in place */
  64. z-index: 9999; /* Sit on top */
  65. padding-top: 100px; /* Location of the box */
  66. left: 0;
  67. top: 0;
  68. width: 100%; /* Full width */
  69. height: 100%; /* Full height */
  70. overflow: auto; /* Enable scroll if needed */
  71. background-color: rgb(0,0,0); /* Fallback color */
  72. background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
  73. }
  74.  
  75. /* Modal Content */
  76. .twb_modal-content {
  77. background-color: #fefefe;
  78. margin: auto;
  79. padding: 20px;
  80. border: 1px solid #888;
  81. width: 1000px;
  82. }
  83.  
  84. /* The Close Button */
  85. .twb_close {
  86. color: #aaaaaa;
  87. float: right;
  88. font-size: 28px;
  89. font-weight: bold;
  90. }
  91.  
  92. .twb_close:hover,
  93. .twb_close:focus {
  94. color: #000;
  95. text-decoration: none;
  96. cursor: pointer;
  97. }
  98. `);
  99. document.querySelector('.twb_close').addEventListener('click',() => {
  100. twb_modal.style.display = "none";
  101. })
  102. document.querySelector('#twb_btn_twbuyer').addEventListener('click', () => {
  103. let baseUrl = location.href;
  104. let postUrl = 'https://search.twbuyer.info/querybyurl';
  105. let data = {
  106. url: baseUrl
  107. }
  108. fetch(postUrl, {
  109. method: 'POST', // or 'PUT'
  110. body: JSON.stringify(data), // data can be `string` or {object}!
  111. headers: new Headers({
  112. 'Content-Type': 'application/json'
  113. })
  114. }).then(response => response.json())
  115. .then((response) => {
  116. // console.log( response )
  117. if (response.status == 'OK') {
  118. let targetUrl = `https://twbuyer.info/ec_item/${response.ID}`;
  119. twb_modal.querySelector('#twb_content').innerHTML = `<iframe src="${targetUrl}" width="960" height="640" frameborder="0" border="0" cellspacing="0"></iframe>`;
  120. twb_modal.style.display = "block";
  121. }
  122. });
  123.  
  124. })
  125.  
  126. })();

QingJ © 2025

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