Skip to content

Commit

Permalink
show button on tumblr video previews. also fuck tumblr
Browse files Browse the repository at this point in the history
  • Loading branch information
Dezaimasu committed Dec 4, 2018
1 parent a82d250 commit 39ebbf1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions js/content-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ const de_contentscript = {
},

nodeTools: {
absoluteMinSize: 50,

observer: new MutationObserver(mutations => {
const target = mutations.pop().target;
de_contentscript.nodeTools.handleAgainOn('load', target);
this.handleAgainOn('load', target);
}),

addSrcObserver: function(node){
Expand Down Expand Up @@ -289,10 +291,10 @@ const de_contentscript = {
return false;
},
isSmallVideo: function(node){
if (node.tagName !== 'VIDEO' || node.videoHeight || node.videoWidth) {
if (node.tagName !== 'VIDEO' || node.videoHeight || node.clientHeight > this.absoluteMinSize) {
return false;
}
de_contentscript.nodeTools.handleAgainOn('loadeddata', node);
this.handleAgainOn('loadeddata', node);
return true;
},
filterByTag: function(tagName){
Expand All @@ -305,11 +307,10 @@ const de_contentscript = {
return node.matches(de_settings.exclusions);
},
filterBySize: function(node, modifier){
const buttonPlaceholderSize = 50;
if (node.tagName === 'IMG' && (node.width < buttonPlaceholderSize || node.height < buttonPlaceholderSize)) {
if (node.tagName === 'IMG' && (node.width < this.absoluteMinSize || node.height < this.absoluteMinSize)) {
return true; // never show on too small images
}
if (!modifier && (node.tagName === 'AUDIO' || de_contentscript.nodeTools.isSmallVideo(node))) {
if (!modifier && (node.tagName === 'AUDIO' || this.isSmallVideo(node))) {
return true; // don't show on audio tags or video tags with small height (would block play button) unless modifier pressed
}
if (de_contentscript.isSeparateTab || ['VIDEO', 'AUDIO'].includes(node.tagName) || modifier) {
Expand Down

0 comments on commit 39ebbf1

Please sign in to comment.