Skip to content

Instantly share code, notes, and snippets.

@closer
Last active October 4, 2020 13:42
Show Gist options
  • Save closer/45a8934c7b4f369da3374456aa43dabc to your computer and use it in GitHub Desktop.
Save closer/45a8934c7b4f369da3374456aa43dabc to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Rakuten Real Price
// @namespace https://gist.github.com/closer
// @version 0.1
// @description 楽天市場の商品価格ナビでポイント還元を加味した価格に補正します。
// @author closer
// @match https://product.rakuten.co.jp/product/-/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
document.querySelectorAll('.specColumnUsed').forEach((a)=>{
const priceElm = a.querySelectorAll('.itemPrice3')[0];
const pointElm = a.querySelectorAll('.hasPtPopup')[0];
const price = parseInt(priceElm.innerText.replace(',',''));
const point = parseInt(pointElm.innerText.replace(',',''));
const discount = price - point;
const discountElm = document.createElement('span');
discountElm.className = 'UsedTxet01 itemPrice3';
discountElm.appendChild(document.createTextNode(discount.toLocaleString()));
const halfyen = document.createElement('span');
halfyen.className = 'halfyen';
halfyen.innerText = '円';
discountElm.appendChild(halfyen);
priceElm.before(discountElm);
priceElm.before(document.createElement('br'));
priceElm.className = null;
priceElm.innerText = `(元値)${priceElm.innerText}`;
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment