Add this as a bookmark in your browser to have button to instantly convert the second listed price from USD to CAD. Should work in both Firefox and Chrome.
Set this as the URL:
javascript:(()=>{var USD_TO_CAD_RATE=-1;function cacheRateToCookie(value){try{var rate=parseFloat(value);if(rate>0)return async function(cname,cvalue,exdays=.5){try{var d=new Date;d.setTime(d.getTime()+24*exdays*60*60*1e3);var expires="expires="+d.toUTCString();document.cookie=cname+"="+cvalue+"; "+expires+";SameSite=None; Secure",console.log("Saved data to cookie.")}catch{console.error("Failed to set cookie.")}}("ACHIDEKT_USD_TO_CAD_PRICE_EXCHANGE_RATE",rate,.5),console.log("Cookie not found. Saved Archidekt USD to CAD exchange rate to cookie (expires in 12 hours)."),!0}catch{return!1}return!1}async function getCookieCachedRate(){const savedNumber=await async function(cname){try{for(var name=cname+"=",ca=document.cookie.split(";"),i=0;i<ca.length;i++){for(var c=ca[i];" "==c.charAt(0);)c=c.substring(1);if(0==c.indexOf(name))return c.substring(name.length,c.length)}}catch{console.error("Failed to get from cookie.")}return-2}("ACHIDEKT_USD_TO_CAD_PRICE_EXCHANGE_RATE");if(void 0!==savedNumber)try{let rate=parseFloat(savedNumber);if(rate>0)return rate}catch{return-2}return-2}function setupPrices(){const originalNode=document.querySelector('[class*="deckPrice_"]');if(originalNode){const originalPrice=parseFloat(originalNode.textContent.replace(/[^0-9.]/g,""));if(!isNaN(originalPrice)){const newPrice=(1.41*originalPrice).toFixed(2),newPriceNode=document.createElement("span");newPriceNode.textContent=` (๐ $${newPrice})`,newPriceNode.style.color="red",newPriceNode.style.fontWeight="bold",newPriceNode.setAttribute("delete-me",1),originalNode.parentNode.insertBefore(newPriceNode,originalNode.nextSibling),console.info(`Updated the deck price. USD = ${originalPrice}. CAD = ${newPrice}.`)}}var cardsUpdated=0;Array.from(document.querySelectorAll('[class*="prices_priceTwo"]')).forEach(el=>{const match=el.textContent.match(/\d+(\.\d+)?/);if(!match)return;const originalPrice=parseFloat(match[0]),newPrice=(1.41*originalPrice).toFixed(2),newEl=document.createElement("span");newEl.textContent=`๐ $${newPrice}`,newEl.style.color="red",newEl.style.fontWeight="bold",newEl.setAttribute("data-original-price",originalPrice),newEl.setAttribute("delete-me",1),el.insertAdjacentElement("afterend",newEl),el.style.display="none",cardsUpdated+=1}),console.info(`Added the CAD (rate = ${USD_TO_CAD_RATE}) price of ${cardsUpdated} card(s).`)}(function(){const node1=document.querySelector('[class*="deckPrice_"]'),node2=document.querySelector('[class*="deckHeader_"]');return null!=node1&&null!=node2})()&&(console.log("Archidekt-CAD by joedf v0.0.1"),async function(){if(document.querySelectorAll('[delete-me="1"]').forEach(el=>el.remove()),await async function(){return!(USD_TO_CAD_RATE>0)&&await getCookieCachedRate()<0}())fetch("https://www.bankofcanada.ca/valet/observations/FXUSDCAD/json?recent=1").then(res=>res.json()).then(data=>{try{let rate=parseFloat(data.observations[0].FXUSDCAD.v);console.log("Fetched USD to CAD rate = "+rate),USD_TO_CAD_RATE=rate,cacheRateToCookie(rate),setupPrices()}catch{console.warn("Failed to update currency exchange rate data...")}}).catch(err=>console.error(err));else if(console.info("Not fetching Archidekt USD to CAD exchange rate - using cached."),USD_TO_CAD_RATE>0)console.log(`Archidekt USD to CAD exchange rate found in memory: ${USD_TO_CAD_RATE}`),setupPrices();else{let rate=await getCookieCachedRate();rate>0?(console.log(`Archidekt USD to CAD exchange rate found in cookie: ${rate}`),USD_TO_CAD_RATE=rate,setupPrices()):console.warn("Archidekt USD to CAD exchange rate FAILED. Please report to plugin author.")}}())})();Pro tips!
- Add it to your bookmarks toolbar and all you have to do is click it!
- You can set a short keyword (e.g.
ardk) as the name of the bookmark, so you can just type it in the address bar (press F6 to focus it) and hit Enter to run it. Or in Firefox, you can set the keyword for it as well instead of the name of the bookmark.