Last active
August 6, 2022 16:14
-
-
Save tan9/3a3e5359a09bd196d32e55c5f492b090 to your computer and use it in GitHub Desktop.
壽險公會保險存摺小工具
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name 保險存摺小工具 | |
// @source https://gist.github.com/tan9/3a3e5359a09bd196d32e55c5f492b090 | |
// @namespace https://gist.github.com/tan9/ | |
// @version 0.1 | |
// @description 將壽險公會「保險存摺」網頁上失效的保單以半透明方式顯示。 | |
// @author Pei-Tang Huang | |
// @downloadURL https://gist.githubusercontent.com/tan9/3a3e5359a09bd196d32e55c5f492b090/raw/ | |
// @updateURL https://gist.githubusercontent.com/tan9/3a3e5359a09bd196d32e55c5f492b090/raw/ | |
// @match https://insurtech.lia-roc.org.tw/my_list.html | |
// @icon https://insurtech.lia-roc.org.tw/assets/images/favicon.ico | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
if (typeof genInsCard === 'function') { | |
let genInsCardOrigin = genInsCard; | |
genInsCard = (insuranceCruuentData, is1stIns) => { | |
let content = genInsCardOrigin(insuranceCruuentData, is1stIns); | |
if (content.indexOf('(有效)') != -1) { | |
content = content.replaceAll(/<li class="(?<type>type\S*)">/g, `<li class="$1 insurance-valid">`) | |
} | |
if (content.indexOf('(失效)') != -1) { | |
content = content.replaceAll(/<li class="(?<type>type\S*)">/g, `<li class="$1 insurance-invalid">`) | |
} | |
return content; | |
} | |
} | |
document.querySelectorAll('.insuranceBx > li') | |
.forEach(li => { | |
if (li.textContent.indexOf("(有效)") != -1) { | |
li.classList.add('insurance-valid'); | |
} | |
if (li.textContent.indexOf("(失效)") != -1) { | |
li.classList.add('insurance-invalid'); | |
} | |
}) | |
document.head.insertAdjacentHTML("beforeend", ` | |
<style> | |
.insurance-invalid { | |
-webkit-filter: grayscale(0.8); | |
opacity: 0.6; | |
} | |
</style>`) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment