mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-11 21:15:44 +02:00
Improve screenshot reliability
This commit is contained in:
parent
762717da1e
commit
c064ef7a30
@ -24,19 +24,26 @@ public FormNotificationScreenshotable(Action callback, FormBrowser owner, Plugin
|
||||
browser.RegisterAsyncJsObject("$TD_NotificationScreenshot", new ScreenshotBridge(this, SetScreenshotHeight, callback));
|
||||
|
||||
browser.LoadingStateChanged += (sender, args) => {
|
||||
if (!args.IsLoading){
|
||||
using(IFrame frame = args.Browser.MainFrame){
|
||||
if (!ScriptLoader.ExecuteFile(frame, "screenshot.js")){
|
||||
this.InvokeAsyncSafe(callback);
|
||||
}
|
||||
}
|
||||
if (args.IsLoading){
|
||||
return;
|
||||
}
|
||||
|
||||
string script = ScriptLoader.LoadResource("screenshot.js", true);
|
||||
|
||||
if (script == null){
|
||||
this.InvokeAsyncSafe(callback);
|
||||
return;
|
||||
}
|
||||
|
||||
using(IFrame frame = args.Browser.MainFrame){
|
||||
ScriptLoader.ExecuteScript(frame, script.Replace("{width}", ClientSize.Width.ToString()), "screenshot");
|
||||
}
|
||||
};
|
||||
|
||||
LoadTweet(new TweetNotification(string.Empty, string.Empty, string.Empty, html, 0, string.Empty, string.Empty));
|
||||
SetScreenshotHeight(1);
|
||||
LoadTweet(new TweetNotification(string.Empty, string.Empty, string.Empty, html, 0, string.Empty, string.Empty));
|
||||
}
|
||||
|
||||
|
||||
protected override string GetTweetHTML(TweetNotification tweet){
|
||||
string html = tweet.GenerateHtml("td-screenshot");
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
(function($TD){
|
||||
let ele = document.getElementsByTagName("article")[0];
|
||||
ele.style.width = window.innerWidth+"px";
|
||||
ele.style.width = "{width}px";
|
||||
|
||||
ele.style.position = "absolute";
|
||||
let contentHeight = ele.offsetHeight;
|
||||
@ -9,6 +9,7 @@
|
||||
let avatar = ele.querySelector(".tweet-avatar");
|
||||
let avatarBottom = avatar ? avatar.getBoundingClientRect().bottom : 0;
|
||||
|
||||
$TD.setHeight(Math.floor(Math.max(contentHeight, avatarBottom+9)));
|
||||
setTimeout($TD.triggerScreenshot, document.getElementsByTagName("iframe").length ? 267 : 67);
|
||||
$TD.setHeight(Math.floor(Math.max(contentHeight, avatarBottom+9))).then(() => {
|
||||
setTimeout($TD.triggerScreenshot, document.getElementsByTagName("iframe").length ? 267 : 67);
|
||||
});
|
||||
})($TD_NotificationScreenshot);
|
||||
|
Loading…
Reference in New Issue
Block a user