-
Notifications
You must be signed in to change notification settings - Fork 0
/
extra.js
83 lines (76 loc) · 2.63 KB
/
extra.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// ==UserScript==
// @name WebAdRule Extra Script
// @version 1.1.0
// @namespace http://tampermonkey.net/
// @match *://*.51cto.com/*
// @match *://*.segmentfault.com/*
// @match *://juejin.cn/*
// @grant GM_addStyle
// @run-at document-start
// @require https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js
// @author xndeye
// @description This script is an extension of the Web Ad Rule to fix something that easylist can't handle
// @license MIT
// @downloadURL https://raw.githubusercontent.com/xndeye/web-ad-rule/master/extra.js
// @updateURL https://raw.githubusercontent.com/xndeye/web-ad-rule/master/extra.js
// ==/UserScript==
(function () {
'use strict';
})();
let domain = null;
function getdomain() {
if (!domain) {
domain = document.location.hostname.split('.').slice(-2).join('.')
console.log('<WebAdRule Extra Script> : ' + domain)
}
return domain ? domain : ''
}
/**
* Inject on document-start
*/
switch (getdomain()) {
default:
break;
}
/**
* Execute after page load
*/
window.onload = function () {
switch (getdomain()) {
case '51cto.com':
setTimeout(function () {
$(".copy_btn").each(function () {
$(this).text('复制');
this.setAttribute('class', 'copy-r');
this.onclick = function () {
var item = $(this.getAttribute('data-clipboard-target'));
if (item[0].tagName === 'CODE') {
navigator.clipboard.writeText(item.text())
} else {
navigator.clipboard.writeText(item.siblings().text());
}
}
});
}, 1000);
break;
case 'juejin.cn':
document.oncopy = event => event.clipboardData.setData('text', window.getSelection(0).toString());
$('a[href]').each(function () {
console.log($(this).html());
let link = $(this).attr('href').replace('https://link.juejin.cn?target=', '');
if (typeof link !== 'undefined') {
$(this).attr('href', decodeURIComponent(link));
}
})
break;
case 'segmentfault.com':
$('.article a[href]').each(function () {
if ($(this).attr('href').startsWith('https://link.segmentfault.com')) {
$(this).attr('href', $(this).text());
}
})
break;
default:
break;
}
}