-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontent.js
50 lines (39 loc) · 1.05 KB
/
content.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
console.log('JIRA RTL');
function setDirAuto(element) {
element.setAttribute("dir", "auto");
// console.log('JIRA RTL: Set Attr');
}
function changeDir() {
var timesRun = 0;
var interval = setInterval(function() {
timesRun += 1;
var ele = document.querySelectorAll('input, textarea, a, p, h1, div');
for (i = 0; i < ele.length; i++) {
setDirAuto(ele[i]);
}
// console.log('JIRA RTL: Set Timeout');
if(timesRun === 1){
clearInterval(interval);
}
}, 1000);
}
window.addEventListener("load", () => {
changeDir();
});
var oldHref = document.location.href;
window.addEventListener("load", () => {
var bodyList = document.querySelector("body")
,observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (oldHref != document.location.href) {
oldHref = document.location.href;
changeDir();
}
});
});
var config = {
childList: true,
subtree: true
};
observer.observe(bodyList, config);
});