Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
filecxx committed Jan 22, 2024
1 parent e54c7b0 commit c0061d2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
7 changes: 6 additions & 1 deletion chrome/content/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,18 @@ chrome.storage.local.get({settings:config.settings,replace_words:config.replace_
{
var html = target.innerHTML;
var body_overflow_hidden = get_element_style(document.body,"overflow") === "hidden";

//var fullscreen_locker = get_element_style(target,"width");
//https://nsfwr34.com/?ref=porndude
//console.log(fullscreen_locker);
var check_text = function(text){
if(!text){
return false;
}
text = target.innerHTML.toLowerCase();

if(text.indexOf("enforcement-message") !== -1){
return true;
}
return text.indexOf("ad") !== -1 && text.indexOf("blocker") !== -1
}
if(body_overflow_hidden && (check_text(html) || check_text(target.className)))
Expand Down
28 changes: 24 additions & 4 deletions chrome/content/content_element_selector.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
var element_selector =
{
get_element_offset:function(element)
{
let rect = element.getBoundingClientRect();
let scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
let scrollTop = window.pageYOffset || document.documentElement.scrollTop;

return {
left: rect.left + scrollLeft,
top: rect.top + scrollTop
};
},
query_selector_all: function(selector)
{
try{
return document.querySelectorAll(selector);
}catch(e){

}
return [];
},
find_unique_id:function(element)
{
while(element = element.parentNode)
Expand Down Expand Up @@ -29,12 +49,12 @@ var element_selector =
}else{
selector = current;
}
if(document.querySelectorAll(selector).length === 1){
if(this.query_selector_all(selector).length === 1){
return {selector:selector,unique:true};
}else if(root_id)
{
var temp_selector = "#" + root_id + " " + selector;
var elements = document.querySelectorAll(temp_selector);
var elements = this.query_selector_all(temp_selector);

if(elements.length === 1){
return {selector:temp_selector,unique:true};
Expand All @@ -55,7 +75,7 @@ var element_selector =
selector = current;
}
}
return {selector:selector,unique:document.querySelectorAll(selector).length === 1};
return {selector:selector,unique:this.query_selector_all(selector).length === 1};
},
make_selector_index:function(element,selector)
{
Expand Down Expand Up @@ -167,7 +187,7 @@ var element_selector =
}
var mouseover = function(e)
{
var offset = get_element_offset(e.target);
var offset = element_selector.get_element_offset(e.target);

elem.style["left"] = offset.left + "px";
elem.style["top"] = offset.top + "px";
Expand Down
3 changes: 3 additions & 0 deletions chrome/libs/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ function get_element_offset(element)
*/
var get_element_style = function(element,styleName,fromElementStyle)
{
if(!element){
return "";
}
var elementStyle = element.style;

if(fromElementStyle !== false && elementStyle && elementStyle[styleName]){
Expand Down

0 comments on commit c0061d2

Please sign in to comment.