(type)
| 49 | |
| 50 | // 强制当前网站使用全局音量(针对部分不支持调节音量的网站) |
| 51 | function menu_forcedToEnable(type) { |
| 52 | switch(type) { |
| 53 | case 'check': |
| 54 | if(check()) return true |
| 55 | return false |
| 56 | break; |
| 57 | case 'add': |
| 58 | add(); |
| 59 | break; |
| 60 | case 'del': |
| 61 | del(); |
| 62 | break; |
| 63 | } |
| 64 | |
| 65 | function check() { // 存在返回真,不存在返回假 |
| 66 | let websiteList = GM_getValue('menu_forcedToEnable',[]); // 读取网站列表 |
| 67 | if (websiteList.indexOf(location.host) === -1) return false // 不存在返回假 |
| 68 | return true |
| 69 | } |
| 70 | |
| 71 | function add() { |
| 72 | if (check()) return |
| 73 | let websiteList = GM_getValue('menu_forcedToEnable',[]); // 读取网站列表 |
| 74 | websiteList.push(location.host); // 追加网站域名 |
| 75 | GM_setValue('menu_forcedToEnable', websiteList); // 写入配置 |
| 76 | location.reload(); // 刷新网页 |
| 77 | } |
| 78 | |
| 79 | function del() { |
| 80 | if (!check()) return |
| 81 | let websiteList = GM_getValue('menu_forcedToEnable',[]), // 读取网站列表 |
| 82 | index = websiteList.indexOf(location.host); |
| 83 | websiteList.splice(index, 1); // 删除网站域名 |
| 84 | GM_setValue('menu_forcedToEnable', websiteList); // 写入配置 |
| 85 | location.reload(); // 刷新网页 |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | |
| 90 | // 网页本身的 Video Audio 标签 |
no test coverage detected