メルカリ系ブックマークレット

Quick Edit Pencil
目次

メルカリ取引画面印刷最適化ブックマークレット

javascript:
/* -----------------------------------------------
メルカリ取引画面印刷最適化ブックマークレット
アプデ:2023/12/26
TAGO.OKに投稿してる
https://tagook.blogspot.com/2018/06/blog-post.html
----------------------------------------------- */
/*商品名を取得*/
var itemName = document.querySelector("mer-item-object");
console.log(itemName);
itemName = itemName.shadowRoot.querySelector(".container").getAttribute('aria-label');
console.log(itemName);
/*タイトルを変更*/
document.title = document.title.replace(' - ', '│' + itemName + ' - ');

/*スタイル属性を追加*/
document.querySelector("aside[aria-label='取引が完了しました'] + div").setAttribute("style", "display:none;");

/*スタイル要素を追加*/
var body = document.getElementsByTagName('body').item(0);
var style = document.createElement('style');
var text = `
footer{display:none!important;}
`;
var rule = document.createTextNode(text);
/*style.media = 'screen';*/
style.type = 'text/css';
style.appendChild(rule);
body.appendChild(style);

/*クリップボードに商品をコピーして印刷ダイアログを開く*/
async function copyToClipboard(text) {
  try {
    await navigator.clipboard.writeText(text);
    console.log('コピーしました');
    /*プリンtダイアログを開く*/
    window.print();
  } catch (error) {
    alert((error && error.message) || 'コピーに失敗しました');
  }
}
copyToClipboard(itemName);

メルカリ商品ページ印刷最適化ブックマークレット

javascript:

/* -----------------------------------------------
メルカリ商品ページ印刷最適化ブックマークレット
アプデ:2023/12/26
TAGO.OKに投稿してる
https://tagook.blogspot.com/2022/04/2022.html
----------------------------------------------- */

/*タイトルを変更*/
document.title = document.title.replace(/商品画像│|商品ページ│/g, '');
document.title = '商品ページ│' + document.title;

/*出品者要素を定義*/
var seller = document.querySelector("a[location-1='seller_info']").parentNode.parentNode;

/*スタイル属性を追加*/
var elms = new Array();
/*メルカリ安心への取り組み*/
elms.push(document.querySelector("a[href='https://static.jp.mercari.com/safe/description']").parentNode);
/*ポイント利用案内*/
elms.push(document.querySelector("#item-info > section > div + section > div + aside"));

/*SoldOutの場合*/
if (document.querySelector("div[aria-label*='売り切れ']")) {
  /*こちらの商品もおすすめです*/
  elms.push(document.querySelector("#item-info div[data-testid*='checkout-button-container'] + section"));
}

/*コメント*/
elms.push(seller.nextSibling);
/*この出品者の商品*/
elms.push(document.querySelector("main article + section"));
/*この商品を見ている人におすすめ*/
elms.push(document.querySelector("main article + section + section"));
/*パンクズ*/
elms.push(document.querySelector("main > div"));
/*フッター*/
elms.push(document.querySelector("footer"));
/*nullを除外*/
elms = elms.filter(Boolean);
for (var i = 0; i < elms.length; i++) {
  console.log(elms[i]);
  elms[i].setAttribute("style", "display:none;");
}
/*スタイル要素を追加*/
var body = document.getElementsByTagName('body').item(0);
var style = document.createElement('style');
var text = `
div[data-testid='vertical-thumbnail-scroll'] .slick-list{height: auto!important;}
div.show-more-button{display:none;}
div.clamp{-webkit-line-clamp: none!important;}
`;
var rule = document.createTextNode(text);
/*style.media = 'screen';*/
style.type = 'text/css';
style.appendChild(rule);
body.appendChild(style);

/*shadow-root商品説明*/
var descriptionOfItem = document.querySelector("div.merShowMore");
var content = descriptionOfItem.querySelector("div[class*='clamp']");
content.setAttribute("style", "-webkit-line-clamp: none");
var button = descriptionOfItem.querySelector("button[data-testid*='show-more-toggle']");
button.setAttribute("style", "display: none");

/*出品者*/
seller.setAttribute("style", "height: 200px");

/*クリップボードに商品名をコピーして印刷ダイアログを開く*/
async function copyToClipboard(text) {
  try {
    await navigator.clipboard.writeText(text);
    console.log('コピーしました');
    /*プリンtダイアログを開く*/
    /*window.print();*/
  } catch (error) {
    alert((error && error.message) || 'コピーに失敗しました');
  }
}
copyToClipboard(document.title);

/*プリンtダイアログを開く*/
window.print();

メルカリ商品イメージ印刷最適化ブックマークレット

javascript:

/* -----------------------------------------------
メルカリ商品イメージ印刷最適化ブックマークレット
アプデ:2023/12/26
TAGO.OKに投稿してる
https://tagook.blogspot.com/2022/04/2022.html
----------------------------------------------- */

/*タイトルを変更*/
document.title = document.title.replace(/商品画像│|商品ページ│/g, '');
document.title = '商品画像│' + document.title;

/*スタイルとスクリプト削除*/
var styleElms = document.querySelectorAll("link,style,script,noscript");
for (var i = 0; i < styleElms.length; i++) {
  console.log(styleElms[i]);
  styleElms[i].remove();
}

/*サムネイルのソースを配列に格納*/
var arrImgSrc = new Array();

var itemimages = document.querySelector("div[aria-label='商品画像カルーセル'] > div + div");

var imagesSrc = itemimages.querySelectorAll("img");
for (var i = 0; i < imagesSrc.length; i++) {
  console.log(imagesSrc[i].src);
  arrImgSrc.push(imagesSrc[i].src);
}

/*ボディを初期化*/
var body = document.body;
body.innerHTML = "";

/*印刷用イメージ要素をクリエイト*/
var img_element;
for (var i = 0; i < arrImgSrc.length; i++) {
  console.log(arrImgSrc[i]);
  img_element = document.createElement('img');
    img_element.src = arrImgSrc[i].replace('s-l64', 's-l1600');
    body.appendChild(img_element);
}

/*スタイル要素を追加*/
var style = document.createElement('style');
var text = `
/*画像調整*/
img
{width:100%;height:auto;padding-top:1px;}
/*非表示*/
button
{display:none!important;}
`;
var rule = document.createTextNode(text);
/*style.media = 'screen';*/
style.type = 'text/css';
style.appendChild(rule);
body.appendChild(style);

/*クリップボードに商品名をコピーして印刷ダイアログを開く*/
async function copyToClipboard(text) {
  try {
    await navigator.clipboard.writeText(text);
    console.log('コピーしました');
    /*プリンtダイアログを開く*/
    /*window.print();*/
  } catch (error) {
    alert((error && error.message) || 'コピーに失敗しました');
  }
}
copyToClipboard(document.title);

このブログの人気の投稿

PowerShellのGetDetailsOf メソッドでプロパティの詳細情報のID番号と項目名を列挙します

書字方向 横書方向変換スクリプト 左書きから右書きへ(コピペ用途)

PowerShellで複数ファイルのプロパティを取得する方法(準備編)

簡単 YouTube動画をダウンロード、音声のみ保存する方法 2019

DOMノードオブジェクトを文字列に変換する

AppleScript 改行 コード 置換

Blender: 辺の長さを数値で指定するアドオン

Powershell: プロパティの詳細情報インデックスと項目名の列挙

VMWare Playerでホストとゲスト間でクリップボードが共有できない時の対処法