-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontent.js
More file actions
93 lines (84 loc) · 2.57 KB
/
content.js
File metadata and controls
93 lines (84 loc) · 2.57 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
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
84
85
86
87
88
89
90
91
92
93
var lastFact = 1,
currentFact = 1;
chrome.extension.onRequest.addListener(function(request, sender, callback) {
if (request.action == "getSource")
{
callback(document.getElementsByTagName('html')[0].innerHTML);
}
else if (request.action == "setFontSize")
{
if(request.type == "medium")
{
callback(request.type);
}
else
{
setFontSize(request.type);
}
}
else if(request.action == "getDimContent")
{
callback(getDimContent());
}
});
function setFontSize(size)
{
var clases = [];
currentFact = 1;
if(size == 'large'){currentFact = 2;}else if(size == 'x-large'){currentFact = 4;}
if(size == 'medium'){
document.documentElement.removeAttribute('ts');
}else{
document.documentElement.setAttribute('ts', size);
}
[].forEach.call(document.querySelectorAll('body *'), function(node) {
var className = node.className.trim();
var nodeid = node.id;
if(className != '' && $("." + className).css('display') != null && $("." + className).css('display') != "none" && node.nodeName != "IMG")
{
node.setAttribute('ts', size);
//console.log(node.id + " - " + node.className)
if($.inArray(className, clases) == -1 && $("." + className).css('position') != null)
{
console.log(node.nodeName + ' - Clase: ' + className + ' - Id: ' + nodeid + ' ---- position');
clases.push(className);
//$("." + className).css('letter-spacing', none);
}
/*if($.inArray(className, clases) == -1 && $("." + className).css('height') != null) {
clases.push(className);
var height = $("." + className).css("height");
var newHeight = getNewHeight(height, size);
//$("." + className).css("cssText", "height: " + newHeight + " !important");
$("." + className).css("height", newHeight);
console.log(node.nodeName + ' - ' + className + ' Height: ' + height + ' - ' + newHeight + ' +++ ' + node.offsetHeight);
}*/
}
else if(node.nodeName != "p" || node.nodeName != "a")
{
node.setAttribute('ts', size);
}
else if(className != '')
{
console.log(node.nodeName + ' - ' + className + ' Height: ' + node.offsetHeight + " ----- False");
}
});
lastFact = currentFact;
}
function getNewHeight(height, size)
{
var heightValue = 0;
var index = height.indexOf("px");
if(height.indexOf("px") != -1){
var strHeight = height.substring(0, index);
heightValue = (parseInt(strHeight) / lastFact) * currentFact;
heightValue = heightValue + "px";
}
return heightValue;
}
function getDimContent()
{
var dimWeb = {};
dimWeb.width = document.body.clientWidth;
dimWeb.height = document.body.clientHeight;
return dimWeb;
}