EnstylerJS

MyDealz Enstyler enhanced features incl. Amazon Mobile Redirect

当前为 2017-08-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name EnstylerJS
  3. // @namespace Enstyler
  4. // @description MyDealz Enstyler enhanced features incl. Amazon Mobile Redirect
  5. // @include https://www.mydealz.de/*
  6. // @include https://www.preisjaeger.at/*
  7. // @include https://nl.pepper.com/*
  8. // @include https://www.hotukdeals.com/*
  9. // @include https://userstyles.org/styles/128262/*
  10. // @include https://www.amazon.*/gp/aw/*
  11. // @version 3.08.171-min
  12. // @grant GM_getValue
  13. // @grant GM_setValue
  14. // @grant GM_xmlhttpRequest
  15. // // gnadelwartz hosted includes
  16. // @require https://cdn.rawgit.com/gnadelwartz/zepto-modules/468559e1b3dc6463a0eada49ff71d7b5407a8a26/zepto-noajax-min.js
  17. // @require https://cdn.rawgit.com/gnadelwartz/GM_config/0e4b1e4c0dd6b08499082c679850ebc0f56e6ca4/GM_config-min.js
  18. // @require https://cdn.rawgit.com/gnadelwartz/Enstyler/4491196c35e3f78e710e604429d6847a05b7e412/translations.js
  19. // @run-at document-start
  20. // ==/UserScript==
  21. // commented source: https://greasyfork.org/de/scripts/24244-enstylerjs-develop?version=212395
  22. // diff to last version: https://greasyfork.org/de/scripts/24244-enstylerjs-develop/diff?v1=212395&v2=209380&context=3&w=1
  23.  
  24. function EnstylerInit() {
  25. (enUserLogin = $(".avatar--type-nav").length) ? (enUserName = $(".navDropDown a").attr(enHREF), enUserName = enUserName.replace(/.*\/profile\/([^\/]+).*/, "$1")) : $(document).on("click", ".test-loginButton", EnstylerLastSeenLast),
  26. enSection = enLocParser.pathname.replace(/\/([^\/]+\/*).*/, "/$1");
  27. }
  28.  
  29. function EnstylerDealActions() {
  30. if ("Hotukdeals" == enInternationalName && (enHasPopup = !0), GM_config.get("enConfDealAction")) {
  31. $("footer ul").length && (enDealFooter = "%0D%0A%0D%0A-- %0D%0A" + $("footer ul li p").first().html().replace(/<br>/g, "%0D%0A").replace(/<.*?>/g, ""));
  32. var e = enLocParser.pathname, n = 0;
  33. switch ("" != enUserName && (e = e.replace(enUserName + "/", "")), $(".ico--type-grid-subNavActive, .thread-list--type-card ").length && (n = 1), enDealAdd = enDealAction[0] + enDealAction[1 + n] + enDealAction[3],
  34. !0) {
  35. case e.endsWith("profile/saved-deals"):
  36. enDealAdd += enDealAction[4] + enDealAction[5 + n], +enDealAction[7], enDealUnbook = !0;
  37. break;
  38.  
  39. case e.endsWith("profile/diskussion"):
  40. case enUserLogin && e.endsWith(enUserName):
  41. enDealAdd += enDealAction[8] + enDealAction[9 + n] + enDealAction[11];
  42. }
  43. enDealAdd = enLangLocalize(enDealActionPreHtml + enDealAdd + enDealAction[12] + enDealAction[13 + n] + enDealAction[15] + "</span>", enDealLang, enLANG), enSocialAdd = enLangLocalize(enDealAction[16] + enDealAction[17] + enDealAction[19], enDealLang, enLANG);
  44. var t = "";
  45. GM_config.get("enConfTouch") && (t = "article span.overflow--wrap-off.text--b .ico:before, article div.js-options.text--b .ico:before, article p.text--b button.ico:before{-webkit-transform: scale(1.5); transform: scale(1.5); width: 1.5em; left: 5px;}article a.btn--circle {-webkit-transform: scale(1.5); transform: scale(1.5); left: -1em; margin-left: 3em; width: 4em;}.vote-down, .vote-up {padding-top: 0.25em; padding-bottom: 0.25em}"),
  46. addStyleString(t);
  47. }
  48. EnstylerAvatarPopup(), EnstylerDealActionsDo();
  49. }
  50.  
  51. function EnstylerDealActionsDo() {
  52. var e, n, t, a, o = GM_config.get("enConfDealAction"), i = GM_config.get("enConfTouch"), s = GM_config.get("enConfPopup"), l = GM_config.get("enConfFixHtml");
  53. (o || i || s || l) && $("article").not(".enClassActionDone, .threadWidget-item, .enClassHidden").each(function() {
  54. var r = "c" != $(this).attr("id")[0];
  55. o && r && (n = $(".thread-title", $(this)), e = $("span.thread-infoRow", $(this)), e.length ? (a = enDealComposeMail($(this), n.text(), n.find("a").attr(enHREF), enDealAdd), e.append(a)) : (a = enDealComposeMail($(this), n.text(), "" + enLocParser, enSocialAdd),
  56. $(this).find("a.btn--twitter").parent().append(a))), i && r && (a = $(this).find("div.aGrid, p.imgFrame--noBorder"), a.length && a.html(a.html().replace(/(<a .*?)href=/, "$1noklick=").replace(/ img--dummy.*" data-lazy-img="{&quot;src&quot;:&quot;/, '" src="').replace(/&quot;,&quot;finishClass&quot;:.* alt="/, '" alt="'))),
  57. l && $(this).find("div.userHtml").each(function() {
  58. $(this).html($(this).html().replace(/[^ -~Ä-ü€$]+|(&nbsp;)+|(\n\r)+|<\/p>|<\/div>|<div>/g, " ").replace(/<p>|<br>( *<br>)+/g, "<br><br>").replace(/(<li>)(<br>)+|<br>*(<br><\/li>)/g, "$1"));
  59. }), s && r && !enHasPopup && $(this).find("a.user, button.user").each(function() {
  60. a = $(this).html(), t = $(this).attr(enHREF), enUserLogin && (n = enPopupUser[0] + t + enPopupUser[1] + a.replace(/<span.*/, "") + enPopupUser[2] + '<a href="' + t + '">' + a.replace(/.*<span class=".* space--mr-1">/, '<span class=" space--mr-1 user link-plain">') + "</a>"),
  61. $(this).html(n);
  62. }), i && r && $(this).find("button .avatar").each(function() {
  63. $(this).prop("outerHTML", $(this).prop("outerHTML").replace(/thread-avatar/, "avatar--type-m"));
  64. }), $(this).addClass("enClassActionDone");
  65. });
  66. }
  67.  
  68. function enDealComposeMail(e, n, t, a) {
  69. return n = encodeURIComponent(enInternationalName + ": " + n), n.length < 100 && e.find("span.thread-price").length && (n += encodeURIComponent(" -> " + e.find("span.thread-price").text().replace(/ |\t/g, ""))),
  70. a.replace(enPATTERN[enHREF], t).replace(enPATTERN[enTEXT], truncStringWord(n, 160, "%20") + "&body=" + n + "%0D%0A%0D%0A" + t + enDealFooter);
  71. }
  72.  
  73. function EnstylerAvatarPopup() {
  74. enUserLogin && GM_config.get("enConfPopup") && addStyleString(".thread-footer-cell a img.avatar.vAlign--all-m.space--mr-1.thread-avatar {display: none;}");
  75. }
  76.  
  77. function EnstylerPagePickerCreate() {
  78. if (EnstylerPagePickerRemove(), GM_config.get("enConfPagePicker")) {
  79. var e, n, t, a = 1, o = 1;
  80. if ($(selectList).empty(), $("div.text--color-charcoalTint").length) {
  81. var i = $("nav > div.text--color-charcoalTint").html().replace(/\r?\n|\r/g);
  82. isNaN(a = parseInt(i.replace(/.*currentPage=/, ""))) && (a = 1), isNaN(o = parseInt(i.replace(/.*lastPage=/, ""))) && (o = a);
  83. }
  84. for (x = 1; x <= o; ) t = document.createElement("option"), t.text = x, selectList.add(t), n = x, e = Math.abs(x - a), x < 10 || 5 > e ? x++ : x < 1e3 && e > 600 ? x += Math.floor(e / 100) : x += Math.floor(e / 2);
  85. a > o && (o = a), o > n && (t = document.createElement("option"), t.text = o, selectList.add(t)), selectList.value = a;
  86. var s = [ ".js-navDropDown-messages", "enPageEnum js-navDropDown-messages vAlign--all-m" ];
  87. $(".test-loginButton").length && (s[0] = ".test-loginButton"), $(".voteBar").length && (s = [ ".voteBar--sticky-off--hide.hAlign--all-r", "enPageEnum subNavMenu-link subNavMenu-btn voteBar--sticky-off--hide" ]),
  88. selectList.setAttribute("class", s[1]), $(s[0]).before(selectList);
  89. }
  90. }
  91.  
  92. function EnstylerPagePickerDo() {
  93. $(".js-sticky .text--color-charcoalTint").length && (selectList.value = parseInt($(".js-sticky .text--color-charcoalTint").html().replace(/\r?\n|\r/g).split('--toW2">' + EnstylerSiteConfig("page"))[1]));
  94. }
  95.  
  96. function EnstylerPageAction() {
  97. var e = "page=" + $(this).val(), n = ("" + enLocParser).replace(/page=.*|#.*/, "");
  98. n += n.endsWith("?") || n.endsWith("&") ? e : "?" + e, "/deals/" == enSection && (n += "#thread-comments"), window.location = n;
  99. }
  100.  
  101. function EnstylerPagePickerRemove() {
  102. $(".enPageEnum").remove();
  103. }
  104.  
  105. function EnstylerBlacklist() {
  106. enUserLogin && !GM_config.get("enConfWhitelist").includes(enUserName) && (GM_config.set("enConfWhitelist", "@" + enUserName + "," + GM_config.get("enConfWhitelist")), GM_config.setValue("enConfWhitelist", GM_config.get("enConfWhitelist")));
  107. var e = GM_config.get("enConfBlacklist").replace(unwantedRegex[0], "");
  108. enBlack = RegExp(e.replace(/^,|,$/g, "").replace(/(.),(.)/g, "$1|$2"), "i"), enBlackTrue = !" ".match(enBlack), enBlackTrue || "" == e || alert(confLang("regexfailed")), enWhite = RegExp(GM_config.get("enConfWhitelist").replace(/^,|,$/g, "").replace(/(.),(.)/g, "$1|$2"), "i"),
  109. enWhiteTrue = !" ".match(enWhite), enBlackTemp = GM_config.get("enConfHideColder"), EnstylerBlacklistRemove(), EnstylerBlacklistDo();
  110. }
  111.  
  112. function EnstylerBlacklistDo() {
  113. if (GM_config.get("enConfBlackEnable") && (enBlackTrue || enBlackTemp >= -900)) {
  114. var e;
  115. $("article").not(".enClassBlackDone, .threadWidget-item").each(function() {
  116. $(this).addClass(enClassBlackDone), e = "c" != $(this).attr("id")[0] ? $("a.thread-category", $(this)).text() + " " + $(".thread-title a", $(this)).text() + " @" + $("a.user", $(this)).text() : $(".userHtml", $(this)).text() + " @" + $(".vwo-user-link", $(this)).text(),
  117. e = e.replace(unwantedRegex[1], " "), enWhiteTrue && e.match(enWhite) || (parseInt($(".vote-temp", $(this)).text()) <= enBlackTemp || enBlackTrue && e.match(enBlack)) && ($(this).addClass(enClassHidden),
  118. enBlacklisted++, EnstylerLastSeenSkip("#" + $(this).attr(enID)));
  119. }), EnstylerBlacklistShow();
  120. }
  121. }
  122.  
  123. function EnstylerBlacklistShow() {
  124. enJSfieldDefs.enConfUnblacklist.label = enUnblackText.replace(enPATTERN[enTEXT], enBlacklisted);
  125. }
  126.  
  127. function EnstylerBlacklistRemove() {
  128. EnstylerBlacklistUnhide(), $(".enClassBlackDone").removeClass(enClassBlackDone);
  129. }
  130.  
  131. function EnstylerBlacklistUnhide() {
  132. enBlacklisted = 0, EnstylerBlacklistShow(), $(".enClassHidden").removeClass(enClassHidden);
  133. }
  134.  
  135. function EnstylerFixedNav() {
  136. if (GM_config.get("enConfNavFixed") && "/deals/" != enSection && "/gutscheine/" != enSection) {
  137. var e = $("header").html();
  138. $("header").replaceWith('<header class="enFixedNav">' + e + "</header>");
  139. var n = myFixedCSS.every;
  140. enSection == EnstylerSiteConfig("discussion") && (n += myFixedCSS.discus), ($(".nav-subheadline").length || "/profile/" == enSection) && (n += myFixedCSS.subnav), n = n.replace(enPATTERN[enTEXT], enMainHeigth),
  141. addStyleString(n);
  142. }
  143. }
  144.  
  145. function EnstylerDealTime() {
  146. TodayStart.setHours(0, 0, 0, 0), ShowTime = 60 * GM_config.get("enConfDealMinTime"), $("section.thread-list--type-card").length || (today = enLangLocalize('<span class="hide--toW2"><EN-LANG:today> </span>', enTimeLang, enLANG),
  147. oclock = enLangLocalize('<span class="hide--toW2"> <EN-LANG:oclock></span>', enTimeLang, enLANG)), yesterday = enLangLocalize("<EN-LANG:yesterday> ", enTimeLang, enLANG), EnstylerDealTimeDo();
  148. }
  149.  
  150. function EnstylerDealTimeDo() {
  151. if (GM_config.get("enConfDealTime")) {
  152. var e, n, t = Date.now();
  153. $("time").not("." + EnstylerTimeSeen).each(function() {
  154. if ($(this).addClass(EnstylerTimeSeen), e = $(this).attr("datetime"), void 0 !== e) DealDate.setTime(1e3 * e); else {
  155. if (e = $(this).text(), e.length < 8 || "Preisjaeger" == enInternationalName) return;
  156. DealDate.setTime(t - 6e4 * (60 * parseInt(e.replace(/.* ([0-9].*) [hu].*/, "$1")) + parseInt(e.replace(/.* ([0-9].*) m.*/, "$1"))));
  157. }
  158. switch (e = $(this).html(), n = (t - DealDate) / 6e4, !0) {
  159. case 60 > n || n > 7200:
  160. return;
  161.  
  162. case n > 1440:
  163. e += " (" + ("" + DealDate).slice(16, 21) + oclock + ")";
  164. break;
  165.  
  166. case TodayStart > DealDate:
  167. e = yesterday + ("" + DealDate).slice(16, 21) + oclock;
  168. break;
  169.  
  170. case n > ShowTime:
  171. e += " (" + today + ("" + DealDate).slice(16, 21) + oclock + ")";
  172. }
  173. $(this).html(e);
  174. });
  175. }
  176. }
  177.  
  178. function EnstylerLastSeen() {
  179. LastSeenOnce && (LastSeenOnce = !1, enSection.match(enMainSectionMatch) ? (enSec = enNewestBase + enSection.replace(/\//, ""), GM_setValue(enNewestBase + "LastSec", enSec), enSeenArticle = GM_getValue(enSec, ""),
  180. EnstylerLastSeenDo(), "" == enLocParser.search && $("article").not(".threadWidget-item").each(function() {
  181. return $(this).length ? (GM_setValue(enSec, $(this).attr(enID)), GM_setValue(enSec + "Last", enSeenArticle), !1) : void 0;
  182. })) : EnstylerLastSeenLast());
  183. }
  184.  
  185. function EnstylerLastSeenDo() {
  186. "" != enSec && ("" != enSeenArticle ? (GM_setValue(enSec + "Last", enSeenArticle), $("#" + enSeenArticle).addClass("enClassMarkArticle")) : GM_setValue(enSec, "thread_1"));
  187. }
  188.  
  189. function EnstylerLastSeenLast() {
  190. enSec = GM_getValue(enNewestBase + "LastSec", ""), GM_setValue(enSec, GM_getValue(enSec + "Last", ""));
  191. }
  192.  
  193. function EnstylerLastSeenSkip(e) {
  194. e == "#" + enSeenArticle && (enSeenArticle = $(e).next().attr(enID), EnstylerLastSeenDo());
  195. }
  196.  
  197. function enCheckUpdates() {
  198. if (GM_config.get("enConfInjectCSS")) {
  199. var e = (Date.now() / 6e4 | 0) - GM_getValue("enLastUpdateCheck", "0");
  200. e > enUpdateInterval && enUpdateCSS();
  201. }
  202. }
  203.  
  204. function enUpdateCSS() {
  205. var e = Date.now() / 6e4 | 0;
  206. enCacheExternalResource(enUpdateUrl + enComposeUpdateOpt(), "Enstyler2_CSS"), GM_setValue("enLastUpdateCheck", e);
  207. }
  208.  
  209. function enComposeUpdateOpt() {
  210. var e = GM_getValue(enCssOpt, "");
  211. if ("" == e || !e.startsWith("#")) return "";
  212. e = e.replace(/\n/g, "");
  213. var n = e.split(";");
  214. e = "";
  215. for (var t = 0; t < n.length; t++) if ("" != n[t]) {
  216. var a = n[t].split(":");
  217. a.length < 2 || (e += "&" + a[1].slice(0, -1) + "=" + a[1]);
  218. }
  219. return e = "?" + e.slice(1);
  220. }
  221.  
  222. function EnstylerSiteConfig(e) {
  223. return enLangLocalize("<EN-LANG:" + e + ">", enSiteConfig, enInternationalName);
  224. }
  225.  
  226. function EnstylerMenuActions() {
  227. EnstylerNavRemove(), enInternational || EnstylerAddNav("Main", "<EN-LANG:discussion>", EnstylerSiteConfig("discussion"), "enMainDiscussion"), EnstylerAddNav("Main", "<EN-LANG:enstyler>", '<EN-LANG:enhref>" target="_blank', "enMainHomepage", "building"),
  228. EnstylerAddNav("MainButton", "<EN-LANG:settings>", showEnstylerConfig, EnstylerButton, "filter-subNavBg");
  229. }
  230.  
  231. function EnstylerAddNav(e, n, t, a, o) {
  232. (void 0 === o || "" == o) && (o = enNavIconPat);
  233. var i = !1, s = enMenuItemCode[e].replace(enPATTERN[enID], a).replace(enPATTERN[enTEXT], n);
  234. o != enNavIconPat && (s = s.split(enNavIconPat).join("--type-" + o)), "function" == typeof t ? i = !0 : s = s.replace(enPATTERN[enHREF], t), "M" == e[0] && ("" == enAddMain && $(".nav-link.navMenu-trigger").click(debounce(300, EnstylerMainDo)),
  235. enAddMain += s, i && (enAddMainFunc[enAddMainCount++] = {
  236. ID: a,
  237. target: t
  238. }));
  239. }
  240.  
  241. function EnstylerMainDo() {
  242. $(".popover-content nav .navMenu-div").first().before(enLangLocalize(enAddMain, enMenuLang, enLANG));
  243. var e = $(".popover--mainNav"), n = 35 * (enAddMain.split(enNavEntry).length - 1) + parseInt(e.attr("style").split("height: ")[1]);
  244. e.attr("style", e.attr("style").replace(/height: [0-9.]*px/, "height: " + n + "px"));
  245. for (var t = 0; enAddMainCount > t; t++) $("section #" + enAddMainFunc[t].ID).click(enAddMainFunc[t].target);
  246. }
  247.  
  248. function EnstylerNavRemove() {
  249. enAddMain = "", enAddMainFunc = [], enAddMainCount = 0, $(".navMenu-page").unbind("click"), $(".enNavEntry").remove();
  250. }
  251.  
  252. function confLang(e) {
  253. return enLangLocalize("<EN-LANG:" + e + ">", enConfigLang, enLANG);
  254. }
  255.  
  256. function showEnstylerConfig() {
  257. enGMConfigOpen ? GM_config.close() : (GM_config.open(), $(".popover--mainNav").remove(), enGMConfigOpen = !0);
  258. }
  259.  
  260. function confLangOpen() {
  261. GM_config.set("enConfLang", GM_getValue("enLang", "")), $('.GM_config button[id$="_saveBtn"]').html(enConfigLang[enLANG].save), $('.GM_config button[id$="_closeBtn"]').html(enConfigLang[enLANG].close);
  262. }
  263.  
  264. function enAmazonMobileRedirect() {
  265. var e = "" + enLocParser;
  266. return e.startsWith("https://www.amazon") ? (GM_config.get("enConfAmazonRedirect") && (e.includes("/gp/aw/d/") ? window.location.assign(e.replace("/gp/aw/d/", "/dp/")) : window.location.assign(e.replace("/gp/aw/ol/", "/gp/offer-listing/"))),
  267. !1) : !0;
  268. }
  269.  
  270. function EnstylerStart() {
  271. EnstylerFixedNav();
  272. EnstylerLastSeen(), EnstylerDealTime(), EnstylerBlacklist(), EnstylerDealActions();
  273. }
  274.  
  275. function EnstylerDelayedInit() {
  276. var e = $(".nav").css("background-color"), n = shadeRGBColor($(".btn--mode-special").first().css("background-color"), .1), t = shadeRGBColor(e, .7);
  277. addStyleString(" .GM_config {background-color: " + e + " !important; color: " + t + "; top: " + enMainHeigth + "px !important;} .GM_config .section_header {background-color: " + shadeRGBColor(e, -.25) + " !important; color: " + t + " !important;} .nav-link-text:hover, .js-navDropDown-messages:hover, .js-navDropDown-activities:hover { background-color: " + shadeRGBColor(e, .1) + " !important;} .GM_config input[type=button] { background-color: " + n + " !important; border-color: " + n + " !important; min-width: 10em;} .GM_config input[type=button]:hover, .btn--mode-special:hover { background-color: " + shadeRGBColor(n, .2) + " !important; border-color: " + shadeRGBColor(n, .2) + " !important;}"),
  278. EnstylerMenuActions(), EnstylerPagePickerCreate(), $(".js-pagi-bottom").bind("DOMSubtreeModified", debounce(100, function() {
  279. EnstylerLastSeenDo(), EnstylerPagePickerDo(), EnstylerDealTimeDo(), EnstylerBlacklistDo(), EnstylerDealActionsDo();
  280. }));
  281. }
  282.  
  283. function WaitForBody() {
  284. if ($("section, footer").length) {
  285. if (GM_config.get("enConfInjectCSS") && addStyleString(GM_getValue("Enstyler2_CSS", ""), 'domain("' + enLocParser.hostname), enLocParser.pathname.match(enDisableScript)) return console.error("disable Enstyler for path: " + enLocParser.pathname),
  286. void console.error("regex: /settings$/");
  287. WaitForDOM();
  288. } else setTimeout(WaitForBody, 10);
  289. }
  290.  
  291. function WaitForDOM() {
  292. myColor = $(".nav, #navigation").css("background-color").replace(/rgba.*/, ""), $(".vwo-deal-button, #footer").length && "" == !myColor ? MAIN() : setTimeout(WaitForDOM, 100);
  293. }
  294.  
  295. function MAIN() {
  296. const e = Date.now();
  297. if (enCheckUpdates(), addStyleString(enCSS), document.body.appendChild(enGMFrame), "userstyles.org" != enInternationalSite) {
  298. if (enAmazonMobileRedirect()) {
  299. var n = shadeRGBColor($(".bg--main").css("background-color"), -.08);
  300. addStyleString(".bg--off {background-color: " + n + "!important;}"), enMainHeigth = getOuterHeight("header"), EnstylerInit(), EnstylerStart(), EnstylerStartupDelay = Date.now() - e, EnstylerDelayedInit();
  301. }
  302. } else GM_config.get("enConfInjectCSS") && addStyleString(GM_getValue("Enstyler2_CSS", ""), "url(https://userstyles.org"), EnstylerHomeButton(), setUserClick(), enSetHome(), GM_config.get("enConfInjectCSS") && addStyleString(".install-status { display: none; }"),
  303. "#style-info" == enLocParser.hash && showNotSaved();
  304. }
  305.  
  306. function showEnstylerCSS() {
  307. enGetHome(), GM_config.open();
  308. }
  309.  
  310. function EnstylerHomeButton() {
  311. $("#advancedsettings_area").attr("class", "advancedsettings_shown"), $(".advanced_button").remove(), $("select, input").unbind(), input.setAttribute("style", "font-size: 1.1em; padding: 0.8em;"), $("#button_middle").after(input),
  312. window.scrollTo(0, 600);
  313. }
  314.  
  315. function setUserClick() {
  316. $("#setting-455195").change(HideShowLogoSelect), $("#setting-451668").change(HideShowEnstyler);
  317. }
  318.  
  319. function enGetHome() {
  320. var e, n, t, a = "";
  321. $("#style-settings select").each(function() {
  322. e = $(this).attr(enID), n = $(this).val(), t = $("option[value=" + n + "]").text(), a += "#" + e + ":" + n + ":" + t + ";\n";
  323. }), $("#style-settings input[type=text]").each(function() {
  324. e = $(this).attr(enID), n = $(this).val(), t = "RGB-Clolor", a += "#" + e + ":" + n + ":" + t + ";\n";
  325. }), $("#style-settings input:checked").each(function() {
  326. e = $(this).attr(enID), n = $(this).val(), t = $("label[for=" + e + "]").text(), a += "#" + e + ":" + n + ":" + t + ";\n";
  327. }), GM_config.set("saveOpt", a), GM_setValue(enCssOpt, a);
  328. }
  329.  
  330. function enSetHome() {
  331. input.value = confLang("options");
  332. var e = GM_getValue(enCssOpt, "");
  333. e = e.replace(/\n/g, "");
  334. var n = e.split(";");
  335. if ("" != e && e.startsWith("#")) {
  336. for (var t = 0; t < n.length; t++) {
  337. var a = n[t].split(":");
  338. a[0].startsWith("#setting") ? ($(a[0]).val(""), $(a[0]).val(a[1])) : a[0].startsWith("#option") ? $(a[0]).prop("checked", !0) : "" != a[0] && console.error('ignoring unkown option: "' + a + '"');
  339. }
  340. addStyleString(GM_config.get("enConfInjectCSS") ? ".install-status { display: none; }" : ".install-status { display: inline; }"), HideShowLogoSelect(), HideShowEnstyler();
  341. }
  342. }
  343.  
  344. function closeOnClick() {
  345. sleepAsync(1e4).then(function() {
  346. window.close();
  347. });
  348. }
  349.  
  350. function showNotSaved() {
  351. input.value = confLang("optnotsave"), EnstylerHomeButton();
  352. }
  353.  
  354. function ShowHideItem(e, n, t, a) {
  355. $("#style-settings " + t).each(function() {
  356. -1 != $(this).text().indexOf(a) && ($(e).val() == n ? $(this).parent().addClass(enClassHidden) : $(this).parent().removeClass(enClassHidden));
  357. });
  358. }
  359.  
  360. function HideShowLogoSelect() {
  361. ShowHideItem("#setting-455195", "ik-logo1", "label", "MyDealz Logo");
  362. }
  363.  
  364. function HideShowEnstyler() {
  365. ShowHideItem("#setting-451668", "ik-compact1", "label", "... ");
  366. }
  367.  
  368. function enSendCSS() {
  369. isMozilla && "#style-info" == enLocParser.hash && "string" == typeof GM_info.scriptHandler && GM_info.scriptHandler.match(/usi/i) && window.open(document.referrer + "/1/" + enComposeCSS());
  370. }
  371.  
  372. function enCatchCSS() {
  373. var e = enLocParser.search.replace(/\?/, "#").replace(/=/g, ":").replace(/\&|$/g, ":notext;\n#");
  374. GM_setValue(enCssOpt, e), GM_setValue("enLastUpdateCheck", 0), window.close();
  375. }
  376.  
  377. function enComposeCSS() {
  378. var e = GM_getValue(enCssOpt, "");
  379. if ("" == e || !e.startsWith("#")) return "";
  380. e = e.replace(/\n/g, "");
  381. var n = e.split(";");
  382. e = "";
  383. for (var t = 0; t < n.length; t++) if ("" != n[t]) {
  384. var a = n[t].split(":");
  385. a.length < 2 || (e += "&" + a[0] + "=" + a[1]);
  386. }
  387. return e = "?" + e.slice(1).replace(/#/g, ""), console.log(e), e;
  388. }
  389.  
  390. function enLangLocalize(e, n, t) {
  391. return e = e.replace(enLangPat, function(e, a) {
  392. return n.hasOwnProperty(t) && n[t].hasOwnProperty(a) ? n[t][a] : a;
  393. }), e.match(enLangPat) ? enLangLocalize(e, n, t) : e;
  394. }
  395.  
  396. function addStyleString(e, n) {
  397. if (void 0 === n && (n = ""), e.match(enUserScript.detect)) {
  398. "" == n && (n = enLocParser.hostname);
  399. var t = e.split(n);
  400. e = "";
  401. for (var a = 1; a < t.length; a++) -1 != t[a].indexOf("{") && (e += t[a].replace(enUserScript.split, "").replace(enUserScript.next, ""));
  402. }
  403. for (var o, i = 0, s = enCSSmax; e.length > s && (o = e.substring(s).indexOf("}.")) > 0; ) addStyleString(e.slice(i, s += o + 1)), i = s, s += enCSSmax;
  404. var l = document.createElement("style");
  405. l.innerHTML = e.slice(i), document.body.appendChild(l);
  406. }
  407.  
  408. function capitalizeFirstLetter(e) {
  409. return e[0].toUpperCase() + e.slice(1);
  410. }
  411.  
  412. function truncStringWord(e, n, t) {
  413. return void 0 === t && (t = " "), e.length > n ? (e = e.substr(0, n - 1), e.substr(0, e.lastIndexOf(t)) + "...") : e;
  414. }
  415.  
  416. function sleepAsync(e) {
  417. return new Promise(resolve => setTimeout(resolve, e));
  418. }
  419.  
  420. function shadeRGBColor(e, n) {
  421. if (void 0 === n && (n = .1), void 0 === e) return "rgba(0,0,0,0)";
  422. var t = e.split(","), a = 0 > n ? 0 : 255, o = 0 > n ? -1 * n : n, i = parseInt(t[0].slice(4)), s = parseInt(t[1]), l = parseInt(t[2]);
  423. return "rgb(" + (Math.round((a - i) * o) + i) + "," + (Math.round((a - s) * o) + s) + "," + (Math.round((a - l) * o) + l) + ")";
  424. }
  425.  
  426. function debounce(e, n) {
  427. var t = null;
  428. return function() {
  429. clearTimeout(t), t = setTimeout(function() {
  430. n.call(this);
  431. }, e);
  432. };
  433. }
  434.  
  435. function enCacheExternalResource(e, n) {
  436. GM_xmlhttpRequest({
  437. method: "GET",
  438. url: e,
  439. onload: function(e) {
  440. var t = e.responseText.replace(/\r\n/g, " ").replace(enStripComments, "").replace(enFixCSS, "100%");
  441. GM_setValue(n, t), addStyleString(t);
  442. },
  443. onerror: function(e) {
  444. alert(confLang("cssfailed"));
  445. }
  446. });
  447. }
  448.  
  449. function getOuterHeight(e) {
  450. e = "string" == typeof e ? document.querySelector(e) : e;
  451. var n = window.getComputedStyle(e), t = parseFloat(n.marginTop) + parseFloat(n.marginBottom);
  452. return Math.ceil(e.offsetHeight + t);
  453. }
  454.  
  455. const enLocParser = location, enInternationalSite = enLocParser.hostname.replace("www.", ""), enInternationalName = capitalizeFirstLetter(enInternationalSite.replace(/^\.|\..*/g, "")), enInternational = "Mydealz" != enInternationalName;
  456.  
  457. var enUpdateInterval = 1440, isMozilla = void 0 === GM_info.scriptHandler || !GM_info.scriptHandler.startsWith("Tamp"), enUserLogin = !1, enUserName = "", enSection = "";
  458.  
  459. const DEBUG = !1;
  460.  
  461. var enInitTime;
  462.  
  463. const enDisableScript = /settings$/, enLangPat = /<EN-LANG:(.*?)>/g;
  464.  
  465. var enLANG;
  466.  
  467. "" == (enLANG = GM_getValue("enLang", "")) && (GM_setValue("enLANG", ""), enLANG = enSiteConfig[enInternationalName].lang);
  468.  
  469. const enDealAction = [ '<a title="<EN-LANG:post>" class="link ico ico--pos-l ico--type-comment-blue linkPlain space--mr-3"href="<ENSTYLER-HREF-HERE>#comment-form" data-handler="track" data-track="{&quot;action&quot;:&quot;scroll_to_comment_add_form&quot;,&quot;label&quot;:&quot;engagement&quot;}">', '<span class="hide--toW3"><EN-LANG:post></span><span class="hide--fromW3 hide--toW2"><EN-LANG:po></span>', "", "</a>", '<a title="<EN-LANG:remove>" class="link text--color-blue ico ico--type-bookmark-blue linkPlain ico--pos-l space--mr-3"data-handler="track replace" data-replace="{&quot;endpoint&quot;:&quot;https://www.mydealz.de/threads/<ENSTYLER-THREADID-HERE>/remove&quot;,&quot;method&quot;:&quot;post&quot;}" data-track="{&quot;action&quot;:&quot;save_thread&quot;,&quot;label&quot;:&quot;engagement&quot;}">', '<span class="hide--toW3"><EN-LANG:remove></span><span class="hide--fromW3 hide--toW2"><EN-LANG:rem></span>', "", "</a>", '<a title="<EN-LANG:edit>" class="link text--color-blue ico ico--type-pencil-blue linkPlain ico--pos-l space--mr-3"href="<ENSTYLER-HREF-HERE>/edit" data-handler="track" data-track="{&quot;action&quot;:&quot;goto_thread_edit_form&quot;,&quot;beacon&quot;:true}">', '<span class="hide--toW3"><EN-LANG:edit></span><span class="hide--fromW3 hide--toW2"><EN-LANG:ed></span>', "", "<span></a>", '<a title="<EN-LANG:mail>" class="link text--color-blue ico ico--type-mail-blue linkPlain ico--pos-l space--mr-3"href="mailto:?subject=<ENSTYLER-TEXT-HERE>" <span class="hide--toW3">', '<span class="hide--toW3"><EN-LANG:mail></span><span class="hide--fromW3 hide--toW2"><EN-LANG:ma></span>', "", "<span></a>", '<a title="<EN-LANG:mail>" class="btn btn--whatsapp btn--circle size--all-xs space--ml-2" style="background-color: #69be28;"', 'href="mailto:?subject=<ENSTYLER-TEXT-HERE>"><span class="ico ico--type-mail-white ico--reduce size--all-xxl">', "</span></a>", "</span></a>" ], enDealMarker = "#thread_";
  470.  
  471. var enDealAdd = "", enSocialAdd, enDealUnbook = !1, enDealFooter = "", enHasPopup = !1;
  472.  
  473. const enDealActionPreHtml = '<span class="js-options bg--em bRad--a space--h-3 space--mt-3 text--b">', enPopupUser = [ '<button class="link" data-handler="track popover" data-track="{&quot;action&quot;:&quot;show_short_user_profile&quot;,&quot;label&quot;:&quot;engagement&quot;}" data-popover="{&quot;endpoint&quot;:&quot;', '/short&quot;,&quot;target&quot;:&quot;#template-popoverLoader&quot;,&quot;layout&quot;:[{&quot;preset&quot;:&quot;e&quot;,&quot;y&quot;:&quot;50%&quot;,&quot;left&quot;:{&quot;offset&quot;:0},&quot;width&quot;:300,&quot;maxWidth&quot;:&quot;100%&quot;}]}">', "</button>" ], EnstylerPageEnum = "enPageEnum", selectList = document.createElement("select");
  474.  
  475. selectList.id = EnstylerPageEnum, selectList.setAttribute("class", EnstylerPageEnum), selectList.onchange = EnstylerPageAction;
  476.  
  477. const enClassHidden = "enClassHidden", enClassBlackDone = "enClassBlackDone";
  478.  
  479. var enBlacklisted = 0;
  480.  
  481. const unwantedRegex = [ /[\[\]\(\)\{\}\?\:\;\!\"\*\+\ ]/g, /[\[\]\(\)\{\}\?\.\:\;\!\"\*\+\,]/g ];
  482.  
  483. var enBlack, enBlackTrue, enWhite, enWhiteTrue, enBlackTemp;
  484.  
  485. const myFixedCSS = {
  486. every: ".enFixedNav { display: block; position: fixed; width: 100%; z-index: 120;} .subNav, .profileHeader, .tabbedInterface, .splitPage-wrapper {margin-top: <ENSTYLER-TEXT-HERE>px}",
  487. subnav: ".subNav {margin-top: 0 !important;} .nav-subheadline {margin-top: <ENSTYLER-TEXT-HERE>px}",
  488. discus: ".tGrid.page2-center.height--all-full {margin-top: calc(<ENSTYLER-TEXT-HERE>px + 10px);} #footer .page-content { padding-top: calc(<ENSTYLER-TEXT-HERE>px + 10px);}"
  489. };
  490.  
  491. var DealDate = new Date(), TodayStart = new Date(), ShowTime, EnstylerTimeSeen = "enTimeSeen", today = "", oclock = "", yesterday, enSec = "", enSeenArticle = "";
  492.  
  493. const enNewestBase = "enNewest" + enInternationalSite;
  494.  
  495. var LastSeenOnce = !0;
  496.  
  497. const enUpdateUrl = "https://userstyles.org/styles/128262/enstyler2-style-your-mydealz.css", enCssOpt = "EnstylerCssOpt", enMainSectionMatch = /^\/$|^\/hot$|^\/new$|^\/settings$|^\/discussed$|^\/hei%C3%9F$|^\/diskutiert$/, enHREF = "href", enID = "id", enTEXT = "text", enPATTERN = {
  498. href: /<ENSTYLER-HREF-HERE>/g,
  499. id: /<ENSTYLER-THREADID-HERE>/g,
  500. text: /<ENSTYLER-TEXT-HERE>/g
  501. }, enNavEntry = "enNavEntry", enMenuItemCode = {
  502. Main: '<a class="enNavEntry navMenu-link" id="<ENSTYLER-THREADID-HERE>" href="<ENSTYLER-HREF-HERE>" data-handler="track" data-track="{&quot;action&quot;:&quot;goto_main_target&quot;,&quot;beacon&quot;:true}"><span class="navMenu-link-ico ico ico--type-discussion-navMenuLayerItem navMenu-ico--selected--type-discussion navMenu-ico--hover--type-discussion"></span><ENSTYLER-TEXT-HERE></a>',
  503. Sub: '<li class="enNavEntry subNavMenu-item--separator test-tablink-discussed"><a href="<ENSTYLER-HREF-HERE>" class="subNavMenu-item subNavMenu-link space--h-4 vAlign--all-m" id="<ENSTYLER-THREADID-HERE>" data-handler="track" data-track="{&quot;action&quot;:&quot;goto_menu_target sort&quot;,&quot;label&quot;:&quot;diskutiert&quot;,&quot;beacon&quot;:true}"><span class="box--all-i size--all-xl vAlign--all-m"><ENSTYLER-TEXT-HERE></span><span class="js-vue-container--threadcount" data-handler="vue" data-vue="{&quot;count&quot;:null}"></span></a></li>',
  504. MainButton: '<a class="enNavEntry navMenu-link" id="<ENSTYLER-THREADID-HERE>"><span class="navMenu-link-ico ico ico--type-discussion"></span><ENSTYLER-TEXT-HERE></a>',
  505. SubButton: '<li class="enNavEntry subNavMenu-item--separator test-tablink-discussed"><a class="subNavMenu-item subNavMenu-link space--h-4 vAlign--all-m" id="<ENSTYLER-THREADID-HERE>"><span class="box--all-i size--all-xl vAlign--all-m"><ENSTYLER-TEXT-HERE></span></a></li>'
  506. }, enMenuItemLength = enMenuItemCode.length, EnstylerButton = "EnstylerButton";
  507.  
  508. var enNavIconPat = "--type-discussion", enAddMain = "", enAddMainFunc = [], enAddMainCount = 0;
  509.  
  510. const enJSAutoUpdate = GM_info.scriptWillUpdate;
  511.  
  512. var enUpdateWindow;
  513.  
  514. const enUnblackText = enLangLocalize("<EN-LANG:unblack> <ENSTYLER-TEXT-HERE> Dealz", enConfigLang, enLANG), enJSfieldDefs = {
  515. enstylerCSS: {
  516. section: [ confLang("features"), "" ],
  517. label: confLang("configcss"),
  518. type: "button",
  519. click: function() {
  520. enUpdateWindow = window.open("https://userstyles.org/styles/128262", "UserCSS", "left=0,top=0"), GM_setValue("enLastUpdateCheck", 0);
  521. }
  522. },
  523. enstylerJS: {
  524. label: confLang("userscript"),
  525. type: "button",
  526. click: function() {
  527. enUpdateWindow = window.open("https://greasyfork.org/scripts/24243-enstylerjs/code/EnstylerJS.user.js", "UserScript", "width=110,height=110,left=0,top=0"), sleepAsync(5e3).then(function() {
  528. enUpdateWindow.close();
  529. });
  530. }
  531. },
  532. dontCookies: {
  533. label: confLang("cookies"),
  534. type: "button",
  535. click: function() {
  536. window.open("https://addons.mozilla.org/firefox/addon/self-destructing-cookies/");
  537. }
  538. },
  539. enConfInjectCSS: {
  540. label: confLang("injectcss"),
  541. type: "checkbox",
  542. default: !0
  543. },
  544. Section: {
  545. section: [ confLang("config"), "" ],
  546. type: "hidden"
  547. },
  548. enConfNavFixed: {
  549. label: confLang("navfixed"),
  550. type: "checkbox",
  551. default: !0
  552. },
  553. enConfDealAction: {
  554. label: confLang("dealaction"),
  555. type: "checkbox",
  556. default: !0
  557. },
  558. enConfPopup: {
  559. label: confLang("userpopup"),
  560. type: "checkbox",
  561. default: !0
  562. },
  563. enConfTouch: {
  564. label: confLang("touch"),
  565. type: "checkbox",
  566. default: !1
  567. },
  568. enConfAmazonRedirect: {
  569. label: confLang("amazon"),
  570. type: "checkbox",
  571. default: !0
  572. },
  573. enConfPagePicker: {
  574. label: confLang("picker"),
  575. type: "checkbox",
  576. default: !0
  577. },
  578. enConfDealTime: {
  579. label: confLang("dealtime"),
  580. type: "checkbox",
  581. default: !0
  582. },
  583. enConfDealMinTime: {
  584. label: confLang("mintime"),
  585. type: "int",
  586. min: 1,
  587. max: 24,
  588. size: 4,
  589. default: 1
  590. },
  591. enConfFixHtml: {
  592. label: confLang("fixhtml"),
  593. type: "checkbox",
  594. default: !0
  595. },
  596. enConfBlackEnable: {
  597. label: confLang("blacklist"),
  598. type: "checkbox",
  599. default: !0
  600. },
  601. enConfHideColder: {
  602. label: confLang("blackcold"),
  603. type: "int",
  604. min: -9999,
  605. max: -9,
  606. size: 4,
  607. default: -19
  608. },
  609. enConfBlacklist: {
  610. label: confLang("black"),
  611. type: "text",
  612. size: 70,
  613. default: confLang("examples")
  614. },
  615. enConfWhitelist: {
  616. label: confLang("white"),
  617. type: "text",
  618. size: 70,
  619. default: ""
  620. },
  621. enConfUnblacklist: {
  622. label: confLang("unblack"),
  623. type: "button",
  624. click: function() {
  625. EnstylerBlacklistUnhide();
  626. }
  627. },
  628. enConfLang: {
  629. label: confLang("lang"),
  630. type: "select",
  631. options: enSiteConfig.languages,
  632. default: ""
  633. },
  634. saveOpt: {
  635. type: "hidden"
  636. }
  637. }, enHomefieldDefs = {
  638. saveOpt: {
  639. section: [ confLang("savecss"), "" ],
  640. label: confLang("howtocss"),
  641. type: "textarea",
  642. size: 70
  643. },
  644. enConfInjectCSS: {
  645. label: confLang("injectcss"),
  646. type: "checkbox",
  647. default: !0
  648. },
  649. enConfLang: {
  650. type: "hidden",
  651. options: enSiteConfig.languages,
  652. default: ""
  653. }
  654. }, enGMFrame = document.createElement("div");
  655.  
  656. enGMFrame.setAttribute("class", "GM_config");
  657.  
  658. var enGMConfigOpen = !1;
  659.  
  660. const enRemoveConfig = [ {
  661. check: !1,
  662. switch: "enConfDealTime",
  663. remove: "enConfDealMinTime"
  664. }, {
  665. check: !1,
  666. switch: "enConfBlackEnable",
  667. remove: "enConfWhitelist"
  668. }, {
  669. check: !1,
  670. switch: "enConfBlackEnable",
  671. remove: "enConfBlacklist"
  672. }, {
  673. check: !1,
  674. switch: "enConfBlackEnable",
  675. remove: "enConfHideColder"
  676. }, {
  677. check: !1,
  678. switch: "enConfBlackEnable",
  679. remove: "enConfUnblacklist"
  680. } ];
  681.  
  682. if (window.location.hostname.endsWith("userstyles.org")) GM_config.init({
  683. id: "GM_config",
  684. title: confLang("headline") + " CSS",
  685. fields: enHomefieldDefs,
  686. events: {
  687. open: function() {
  688. confLangOpen();
  689. },
  690. save: function() {
  691. enSendCSS(), enSetHome(), enUpdateCSS(), EnstylerHomeButton(), GM_config.close();
  692. },
  693. close: function() {
  694. enGMConfigOpen = !1;
  695. }
  696. },
  697. frame: enGMFrame
  698. }); else {
  699. var enFixedNavLast = !1;
  700. GM_config.init({
  701. id: enInternational ? "GM_config" + enInternationalSite : "GM_config",
  702. title: confLang("headline"),
  703. fields: enJSfieldDefs,
  704. events: {
  705. open: function() {
  706. enFixedNavLast = GM_config.get("enConfNavFixed"), confLangOpen(), $(enRemoveConfig).each(function() {
  707. GM_config.get(this["switch"]) == this.check && GM_config.fields[this.remove].remove();
  708. }), enJSAutoUpdate && GM_config.fields.enstylerJS.remove(), isMozilla || GM_config.fields.dontCookies.remove(), enHasPopup && GM_config.fields.enConfPopup.remove();
  709. },
  710. save: function() {
  711. "auto" == GM_config.get("enConfLang") ? GM_setValue("enLang", "") : GM_setValue("enLang", GM_config.get("enConfLang")), GM_config.get("enConfNavFixed") || GM_config.get("enConfNavFixed") == enFixedNavLast || window.location.reload(!1),
  712. GM_config.close(), enCheckUpdates(), EnstylerStart(), EnstylerMenuActions(), EnstylerPagePickerCreate(), GM_config.open();
  713. },
  714. close: function() {
  715. enGMConfigOpen = !1;
  716. }
  717. },
  718. frame: enGMFrame
  719. });
  720. }
  721.  
  722. var enCSS = ".threadWidget-footer::after {display: none !important}; .GM_config {left: 5% !iportant; top: 8% !important; height: auto !important; max-width: 35em !important; background-color: white;} .GM_config input, .GM_config button, .GM_config textarea { border: 1px solid; margin: 0.5em 0em 0.2em 1em; padding: 0.1em;} .GM_config .reset { font-size: 9pt; padding-right: 1em; } .enClassHidden, #EnPopup_closeBtn {display: none;}", enMainHeigth, input = document.createElement("input");
  723.  
  724. input.type = "button", input.setAttribute(enID, EnstylerButton), input.onclick = showEnstylerCSS, input.value = confLang("options"), !enLocParser.hostname.endsWith("usertyle.org") && enLocParser.search.match(/ik-maxwidth/i) && enCatchCSS();
  725.  
  726. const enUserScript = {
  727. detect: /.*?@-moz-document .*?\{\s*/,
  728. split: /^.*?\{/,
  729. next: /}\s*@-moz-document.*/
  730. }, enCSSmax = 16100, enStripComments = /\/\*.*?\*\/| *|\t/g, enFixCSS = /1111.11%/g;
  731.  
  732. WaitForBody();