Greasy Fork 还支持 简体中文。

EnstylerJS

MyDealz Enstyler enhanced features incl. Amazon Mobile Redirect

目前為 2017-03-09 提交的版本,檢視 最新版本

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