-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapatw-ui-unlock.user.js
More file actions
50 lines (42 loc) · 1.17 KB
/
apatw-ui-unlock.user.js
File metadata and controls
50 lines (42 loc) · 1.17 KB
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
// ==UserScript==
// @name APATW 解除操作限制
// @description 解除 www.apatw.org(中華民國保護動物協會)網站的文字選取、右鍵選單限制
// @version 1.0.0
// @license MIT
// @author bootleq
// @namespace bootleq.com
// @homepageURL https://github.com/bootleq/user-scripts
//
// @match https://www.apatw.org/*
// @run-at document-idle
// @grant none
// ==/UserScript==
'use strict';
const $body = document.body;
function init() {
resetStyles();
stopEventPropagation();
}
function resetStyles() {
const prefixes = ['webkit', 'khtml', 'moz', ''];
const cssProp = 'user-select';
const el = $body;
if (el) {
const computedStyle = window.getComputedStyle(el);
for (let k = prefixes.length - 1; k >= 0; k--) {
const prefix = prefixes[k];
const style = (prefix ? `-${prefix}-` : '') + cssProp;
if (computedStyle[style] === 'none') {
el.style[style] = 'auto';
}
}
}
}
function stopEventPropagation() {
const event = 'contextmenu';
document.addEventListener(event, function(e) {
e.stopPropagation();
e.stopImmediatePropagation();
}, true);
}
init();