UserCSS-本文リンクにamzn.toがあるとき、ページにアソシエイト参加中の一文を追加する
#css #UserCSS
code:style.css
body {
--shopcart-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='12' width='13.5' viewBox='0 0 576 512'%3E%3C!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--%3E%3Cpath fill='%232aa198' d='M0 24C0 10.7 10.7 0 24 0L69.5 0c22 0 41.5 12.8 50.6 32l411 0c26.3 0 45.5 25 38.6 50.4l-41 152.3c-8.5 31.4-37 53.3-69.5 53.3l-288.5 0 5.4 28.5c2.2 11.3 12.1 19.5 23.6 19.5L488 336c13.3 0 24 10.7 24 24s-10.7 24-24 24l-288.3 0c-34.6 0-64.3-24.6-70.7-58.5L77.4 54.5c-.7-3.8-4-6.5-7.9-6.5L24 48C10.7 48 0 37.3 0 24zM128 464a48 48 0 1 1 96 0 48 48 0 1 1 -96 0zm336-48a48 48 0 1 1 0 96 48 48 0 1 1 0-96z'/%3E%3C/svg%3E");
}
ページ上部に追加
code:style.css
main.page:has(a[href^='https://amzn.to/'])::before {
content: ' Amazonアソシエイト・プログラム参加中';
color: #2aa198;
padding-left: 22px;
background-size: 18px 100%;
background-image: var(--shopcart-image);
background-repeat: no-repeat;
}
リンクの後ろにカートアイコンをつける
code:style.css
/* 文字列用 */
a[href^='https://amzn.to/']::after{
content: var(--shopcart-image) !important;
}
/* 画像リンク用 / リンクされているURLも表示する */
a[href^='https://amzn.to/']:has(img)::after{
font-weight: 400 !important;
font-size: 85% !important;
margin-left: .5em;
padding-right: 1.5rem;
content: attr(href) !important;
background-image: var(--shopcart-image);
background-repeat: no-repeat;
background-position: 100% 70%;
}