-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
42 lines (38 loc) · 1.61 KB
/
content.js
File metadata and controls
42 lines (38 loc) · 1.61 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
(() =>{
// If it is set to a detailed match on the manifest, it sometimes fails, so the exception is handled like this...
if(window.name !== 'cafe_main') return;
try{
let _done = false;
const url = document.location.href;
// 1. If it is the main site, change the browser address the global variable Cafe address url. 'g_sCafeHome'
if(url.includes('cafe.naver.com/MyCafeIntro.nhn')){
document.documentElement.setAttribute('onreset', 'window.parent.history.replaceState(null, null, g_sCafeHome);');
document.documentElement.dispatchEvent(new CustomEvent('reset'));
document.documentElement.removeAttribute('onreset');
return;
}
// 2. Change the browser address to the current main content url.
if(!['ArticleRead.nhn', '/articles/'].some(x => url.includes(x))){
window.parent.history.replaceState(null, null, url);
}
// 3. If it is a post, change it to a clearer address url.
$(document).arrive('a#spiButton.naver-splugin', {
existing: true
},function(spiBtn){
const inUrl = spiBtn.getAttribute('data-url');
if(inUrl != null){
window.parent.history.replaceState(null, null, inUrl);
_done = true;
}
});
// 4. If some time has passed, it is assumed that the url is not a post.
setTimeout(() => {
if(!_done){
window.parent.history.replaceState(null, null, url);
}
}, 500);
}
catch(e){
console.log("error: ", e);
}
})();