My Ref on Amazon (auch über MD)

Unterstütze einen Ref deiner Wahl

  1. // ==UserScript==
  2. // @name My Ref on Amazon (auch über MD)
  3. // @namespace http://dealz.rrr.de/
  4. // @version 20.09.222
  5. // @description Unterstütze einen Ref deiner Wahl
  6. // @author Gnadelwartz
  7. // @match https://www.amazon.de/*
  8. // @grant GM_getValue
  9. // @grant GM_setValue
  10. // @require https://code.jquery.com/jquery-3.5.1.slim.min.js
  11. // @require https://cdn.jsdelivr.net/gh/gnadelwartz/GM_config@3bfccb1cb4238694566ec491ee83d8df94da18d5/GM_config-min.js
  12. // @run-at document-start
  13. // ==/UserScript==
  14. var myRef=GM_getValue( "myRef", "tag=offtopic-21");
  15. var startDate = new Date().getTime();
  16. var lastDate = GM_getValue( "lastDate", "0");
  17.  
  18. var enMyLocation=window.location.href;
  19. // redirect smile to www
  20. enMyLocation.replace(/smile\.amazon\.de\//i, "www.amazon.de/");
  21. // valid order done
  22. if( enMyLocation.includes(".amazon.de/gp/buy/thankyou")) {
  23. setTimeout(function() {
  24. window.location.href="https://www.amazon.de/?"+myRef;
  25. }, 2000);
  26. }
  27. // current tag= is not in URL
  28. if( enMyLocation.includes(".amazon.de") && ! enMyLocation.includes(myRef)) {
  29. // convert old format to current
  30. if (enMyLocation.includes("/exec/obidos/")) {
  31. GM_setValue( "lastDate", startDate);
  32. window.location.href=enMyLocation.replace(/\/exec\/obidos\/ASIN\/(..........).*/i, "/dp/$1/?"+myRef);
  33. }
  34. // found tag, replace with myRef
  35. if (/[?&]tag=/i.test(enMyLocation)) {
  36. GM_setValue( "lastDate", startDate);
  37. window.location.href=enMyLocation.replace(/([?&])tag=.*(-21)*/i, "$1"+myRef);
  38. } else {
  39. // no tag, add myRef every x minutes
  40. if ( (startDate - parseInt(lastDate)) > 60000*5) {
  41. GM_setValue( "lastDate", startDate);
  42. if(enMyLocation.includes("?")) {
  43. // no parameter, use ? for ref
  44. window.location.href=enMyLocation+"&"+myRef;
  45. } else {
  46. // parameter, use & for ref
  47. window.location.href=enMyLocation+"?"+myRef;
  48. }
  49. }
  50.  
  51. }
  52. }
  53.  
  54. GM_config.init(
  55. {
  56. 'id': 'MyRef', // The id used for this instance of GM_config
  57. 'title': 'My Ref Config',
  58. 'fields': // Fields object
  59. {
  60. 'select':
  61. {
  62. 'label': '<br>W&auml;hle einen vordefinierten Ref oder Freitext f&uuml;r einen eigenen Ref', // Appears next to field
  63. 'section': ['Setze einen Ref für Amazon.de', 'Es wurde noch kein Ref ausgew&auml;hlt oder Du willst den Ref &auml;ndern'],
  64. 'type': 'radio', // Makes this setting a series of radio elements
  65. 'options': ['dealz.rrr.de <a target="_blank" href="https://dealz.rrr.de">&gt;&gt;</a><br>',
  66. 'suppentanten.de <a target="_blank" href="http://suppentanten.de">&gt;&gt;</a><br>',
  67. 'elektriker-ohne-grenzen.de <a target="_blank" href="https://elektriker-ohne-grenzen.de">&gt;&gt;</a><br>',
  68. 'BoD Zirkel - geheim ;-)<br>',
  69. 'Do not track!<br><br>',
  70. 'Freitext'], // Possible choices
  71. 'default': '' // Default value if user doesn't change it
  72. },
  73. 'text': // This is the id of the field
  74. {
  75. 'label': 'Ref in der Form <em>"tag=xxx-21"</em>', // Appears next to field
  76. 'type': 'text', // Makes this setting a text field
  77. 'default': myRef // Default value if user doesn't change it
  78. }
  79. },
  80. 'css': '#myRef {margin: 0.4em; background-color: gainsboro;} #MyRef .config_var {margin: 0px; padding: 0 10 0 3em;} #myRef div, #myRef button, #MyRef_section_desc_0 {padding: 0.2em; border-radius: 4px}',
  81. 'events': // Callback functions object
  82. {
  83. 'save': function() { setConfig(); },
  84. }
  85. });
  86.  
  87. function setConfig() {
  88. switch (GM_config.get('select').charAt(0)) {
  89. case "d":
  90. myRef="tag=offtopic-21";
  91. break;
  92. case "s":
  93. myRef="tag=suppentante-21";
  94. break;
  95. case "e":
  96. myRef="tag=elekohnegren-21";
  97. break;
  98. case "B":
  99. myRef="tag=speck-21";
  100. break;
  101. case "D":
  102. myRef="tag=donotrack-21";
  103. break;
  104. case "F":
  105. var tmp=GM_config.get('text')
  106. if (tmp.startsWith("tag=") && tmp.endsWith("-21")) {
  107. myRef=tmp;
  108. } else {
  109. alert("Eingegebener Text entspricht nicht dem Muster tag=xxx-21, setze auf default.")
  110. myRef="tag=offtopic-21"
  111. }
  112. break;
  113. default:
  114. myRef="tag=offtopic-21";
  115. break;
  116. }
  117. GM_setValue("myRef",myRef);
  118. GM_config.close();
  119. }
  120.  
  121. function setRef() {
  122. GM_config.open();
  123. }
  124.  
  125. function readyFn( jQuery ) {
  126. // insert button for config
  127. $( "#nav-tools" ).prepend(
  128. "<div id='myRefConfig' class='nav-a nav-a-2 icp-link-style-2' style='color: #FFCC00; padding-top: .5em; cursor: pointer;'>myR</div>"+
  129. "<style>.nav-search-field {min-width: 15em !important;}</style>"
  130. );
  131. $( "#myRefConfig" ).click(function() {
  132. setRef();
  133. });
  134. // no ref saved, ask for one
  135. if (GM_getValue( "myRef", "") == "") {
  136. setRef();
  137. }
  138. }
  139.  
  140. $( document ).ready( readyFn );

QingJ © 2025

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