-
Notifications
You must be signed in to change notification settings - Fork 0
/
pchome-search-enhancement.user.js
53 lines (43 loc) · 1.76 KB
/
pchome-search-enhancement.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// ==UserScript==
// @name PChome search enhancement
// @namespace https://wiki.gslin.org/wiki/PChomeSearchEnhancement
// @version 0.20180912.0
// @description Ignore non-buyable items in PChome search page.
// @author Gea-Suan Lin <darkkiller@gmail.com>
// @license MIT
// @match https://ecshweb.pchome.com.tw/search/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
let sheet = document.createElement('style');
sheet.innerHTML = '.nonbuyable {opacity:0.33;}';
document.getElementsByTagName('head')[0].appendChild(sheet);
// Add three buttons inside #FilterBar.
let toolbar = document.createElement('span');
toolbar.innerHTML = '<button id="btn_grey">Grey</button> <button id="btn_hide">Hide</button> <button id="btn_disable">Disable</button>';
let el = document.querySelector('.Cm_N .bar_spinbtn');
if (!el) {
return;
}
el.appendChild(toolbar);
document.getElementById('btn_grey').addEventListener('click', function(){
sheet.innerHTML = '.nonbuyable {opacity:0.33;}';
});
document.getElementById('btn_hide').addEventListener('click', function(){
sheet.innerHTML = '.nonbuyable {display:none;}';
});
document.getElementById('btn_disable').addEventListener('click', function(){
sheet.innerHTML = '';
});
let content = document.getElementById('CONTENT');
let selector = '.col3f:has(li.orderNotyet), .col3f:has(li.orderReplenish), .col3f:has(li.soldOut)';
let ob = new window.MutationObserver(function(el){
window.jQuery(selector, el.target).addClass('nonbuyable');
});
ob.observe(content, {
childList: true,
subtree: true,
});
window.jQuery(selector).addClass('nonbuyable');
})();