// ==UserScript== // @name Send wishlist to price-notification server // @version 0.11 // @description Send wishlist to price-notification server // @author Attila BenÅ‘ // @grant GM_setValue // @grant GM_getValue // @grant GM_xmlhttpRequest // @include *://www.daz3d.com/* // @downloadURL http://www.civilizationhunt.com/ds/sendwishlist.user.js // @updateURL http://www.civilizationhunt.com/ds/sendwishlist.user.js // ==/UserScript== (function(){ 'use strict'; if (localStorage.getItem("dazdealsimportedwlsettings") === null) { var ui = JSON.parse(localStorage["User/info"]); var own = JSON.parse(localStorage["Catalog/owned"]); own = own.owned.join(); var ci = ui.customerId; var c; var hide = localStorage.getItem("atihideitems"); // Prep for port over to extension localStorage.setItem("atiwlemail",GM_getValue("atiwlemail")); localStorage.setItem("atiwlcode",GM_getValue("atiwlcode")); localStorage.setItem("atiwlperc",GM_getValue("atiwlperc")); localStorage.setItem("atiwlautoupdate",GM_getValue("atiwlautoupdate")); // Did wishlist change? if (GM_getValue("atiwlautoupdate") && ci > 1) { var chg = GM_getValue("atiwlchecksum"); var currentchecksum = ui.wishlistItems.join() + ui.groupId + own; if (chg !== currentchecksum) { console.log("Wishlist needs uploading."); if (ui.groupId === 8) { c = "checked"; } else { c = ""; } var data = 'email='+GM_getValue("atiwlemail")+'&pass='+GM_getValue("atiwlcode")+'&pc='+c+'¬if='+GM_getValue("atiwlperc")+'&ids='+ui.wishlistItems.join(); if (own !== "") { data = data + "&own="+own+"&hide="+hide; } GM_xmlhttpRequest({ method: "POST", url: "http://www.civilizationhunt.com/ds/updatewishlist.php", data: data, headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, onload: function(response) { if (response.responseText.substring(0,27) === "Wishlist upload successful.") { console.log("Wishlist uploaded successfully."); GM_setValue("atiwlchecksum",ui.wishlistItems.join() + ui.groupId + own); GM_setValue("atiwllastupdate",Date()); } else { alert("Problem with wishlist autoupdate. Check settings on Wishlist page."); } } }); } } var wl = document.getElementsByClassName("my-wishlist"); if (typeof wl[0] !== "undefined") { wl = true; } else { wl = false; } if (wl) { if (ui.groupId === 8) { c = "checked"; } else { c = ""; } var para4 = document.createElement("div"); var a = GM_getValue("atiwlemail"); var b = GM_getValue("atiwlcode"); var d = GM_getValue("atiwlperc"); var e = GM_getValue("atiwlautoupdate"); var f = GM_getValue("atiwllastupdate"); if (a === undefined) { a = ""; } if (b === undefined) { b = ""; } if (d === undefined) { d = ""; } if (e === undefined) { e = ""; } para4.innerHTML = '
'; if (f !== undefined) { para4.innerHTML = para4.innerHTML + 'Last autoupdate: '+f; } para4.style = 'align:center;width:800px;background-color:#cccccc;margin:10px 10px 10px 10px;padding: 10px 10px 10px 10px;'; var para5 = document.createElement("button"); para5.innerHTML = 'Save and manually update wishlist to notification server'; para5.style = 'outline:none;background: #3498db;background-image: -webkit-linear-gradient(top, #3498db, #2980b9);background-image: -moz-linear-gradient(top, #3498db, #2980b9);background-image: -ms-linear-gradient(top, #3498db, #2980b9);background-image: -o-linear-gradient(top, #3498db, #2980b9);background-image: linear-gradient(to bottom, #3498db, #2980b9);-webkit-border-radius: 28;-moz-border-radius: 28;border-radius: 28px;text-shadow: 1px 1px 3px #666666;font-family: Georgia;color: #ffffff;font-size: 20px;padding: 10px 20px 10px 20px;text-decoration: none;'; para5.onclick = function(){ GM_setValue("atiwlemail",document.getElementById("atiwlemail").value); GM_setValue("atiwlcode",document.getElementById("atiwlpass").value); GM_setValue("atiwlperc",document.getElementById("atiwlperc").value); if (document.getElementById("atiwlautoupdate").checked) { GM_setValue("atiwlautoupdate","checked"); } else { GM_setValue("atiwlautoupdate",""); } document.getElementById("atiids").value=ui.wishlistItems.join(); document.getElementById("atiwishlistform").submit(); }; para4.appendChild(para5); document.getElementsByClassName("page-title")[0].appendChild(para4); } } })();