-
Notifications
You must be signed in to change notification settings - Fork 0
/
facebook_heb_align.user.js
40 lines (35 loc) · 1.13 KB
/
facebook_heb_align.user.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
// ==UserScript==
// @name Facebook right align
// @namespace http://tx.technion.ac.il/~ido
// @description Align paragraph to right.
// @include https://www.facebook.com/*
// @include http://www.facebook.com/*
// @author Ido Z
// @grant none
// ==/UserScript==
function getHeb(x) {
a = x.match(/[אבגדהוזחטיכלמנסעפצקרשת]/);
return null!=a;
}
function myfunc() {
var divs = document.evaluate('//div[@role="article"]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
if ( divs.snapshotLength == 0 )
return;
// var username = logout.snapshotItem( 0 ).innerHTML.replace( / /gi, '' ).replace( /.*\[\s+(.+)\s+\].*/i, '$1' );
for (i=0;i<divs.snapshotLength;i++) {
cur = divs.snapshotItem(i);
if (getHeb(cur.innerHTML))
cur.style.textAlign = 'right';
}
}
function myfunc2() { // updated: Thanks GIR.
var css = document.createElement("style");
css.type = "text/css";
css.innerHTML = "[dir=rtl]{text-align:right;display:block;}";
document.body.appendChild(css);
}
DOM = function() {
//myfunc();
//self.setInterval(function(){myfunc()},500);
myfunc2();
}();