Browse Source

improve css/boundary calculation again

Mike L 3 years ago
parent
commit
3639dea0e8
3 changed files with 8 additions and 18 deletions
  1. 4 9
      dist/webshot.js
  2. 0 0
      dist/webshot.js.map
  3. 4 9
      src/webshot.ts

+ 4 - 9
dist/webshot.js

@@ -80,7 +80,7 @@ class Webshot extends CallableInstance {
                     })
                         .then(() => page.goto(url, { waitUntil: 'load', timeout: getTimeout() }))
                         .then(() => page.addStyleTag({
-                        content: 'header{display:none!important}[data-testid="caret"],[data-testid="tweet"]+*>:nth-last-child(-n+2){display:none}',
+                        content: 'header,#layers{display:none!important}[data-testid="caret"],[role="group"],[data-testid="tweet"]+*>:nth-last-child(2){display:none}',
                     }))
                         .then(() => page.addStyleTag({
                         content: '*{font-family:-apple-system,".Helvetica Neue DeskInterface",Hiragino Sans,Hiragino Sans GB,sans-serif!important}',
@@ -144,15 +144,10 @@ class Webshot extends CallableInstance {
                             const idx = (x, y) => (this.width * y + x) << 2;
                             let boundary = null;
                             const x = zoomFactor * 2;
-                            for (let y = 0; y < this.height; y += zoomFactor) {
-                                if (this.data[idx(x, y)] !== 255 &&
+                            for (let y = x; y < this.height; y += zoomFactor) {
+                                if (this.data[idx(x, y)] !== this.data[idx(x, y - zoomFactor)] &&
                                     this.data[idx(x, y)] === this.data[idx(x + zoomFactor * 10, y)]) {
-                                    if (this.data[idx(x, y + 18 * zoomFactor)] !== 255) {
-                                        boundary = null;
-                                    }
-                                    else {
-                                        boundary = y;
-                                    }
+                                    boundary = y;
                                     break;
                                 }
                             }

File diff suppressed because it is too large
+ 0 - 0
dist/webshot.js.map


+ 4 - 9
src/webshot.ts

@@ -106,7 +106,7 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
             .then(() => page.goto(url, {waitUntil: 'load', timeout: getTimeout()}))
             // hide header, "more options" button, like and retweet count
             .then(() => page.addStyleTag({
-              content: 'header{display:none!important}[data-testid="caret"],[data-testid="tweet"]+*>:nth-last-child(-n+2){display:none}',
+              content: 'header,#layers{display:none!important}[data-testid="caret"],[role="group"],[data-testid="tweet"]+*>:nth-last-child(2){display:none}',
             }))
             .then(() => page.addStyleTag({
               content: '*{font-family:-apple-system,".Helvetica Neue DeskInterface",Hiragino Sans,Hiragino Sans GB,sans-serif!important}',
@@ -172,17 +172,12 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
                 const idx = (x: number, y: number) => (this.width * y + x) << 2;
                 let boundary: number = null;
                 const x = zoomFactor * 2;
-                for (let y = 0; y < this.height; y += zoomFactor) {
+                for (let y = x; y < this.height; y += zoomFactor) {
                   if (
-                    this.data[idx(x, y)] !== 255 &&
+                    this.data[idx(x, y)] !== this.data[idx(x, y - zoomFactor)] &&
                     this.data[idx(x, y)] === this.data[idx(x + zoomFactor * 10, y)]
                   ) {
-                    if (this.data[idx(x, y + 18 * zoomFactor)] !== 255) {
-                      // footer kicks in
-                      boundary = null;
-                    } else {
-                      boundary = y;
-                    }
+                    boundary = y;
                     break;
                   }
                 }

Some files were not shown because too many files changed in this diff