Skip to content

Instantly share code, notes, and snippets.

@tan9
Last active August 6, 2022 16:14
Show Gist options
  • Save tan9/3a3e5359a09bd196d32e55c5f492b090 to your computer and use it in GitHub Desktop.
Save tan9/3a3e5359a09bd196d32e55c5f492b090 to your computer and use it in GitHub Desktop.
壽險公會保險存摺小工具
// ==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