Last active
January 6, 2020 13:08
-
-
Save ailispaw/3a62870d1f6e7a7a9a7b489adb865d64 to your computer and use it in GitHub Desktop.
Taberareloo: Fix the size of the popup window
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==Taberareloo== | |
// { | |
// "name" : "Fix the size of the popup window" | |
// , "description" : "Fix the size of the popup window" | |
// , "include" : ["popup"] | |
// , "version" : "0.1.0" | |
// , "downloadURL" : "https://gist.githubusercontent.com/ailispaw/3a62870d1f6e7a7a9a7b489adb865d64/raw/patch.fix.popup.form.resize.tbrl.js" | |
// } | |
// ==/Taberareloo== | |
(function() { | |
update(Form, { | |
resize: function() { | |
var query = queryHash(location.search); | |
if (!query.quick) { | |
return defer(); | |
} | |
if (!Form.nowResizing) { | |
Form.nowResizing = true; | |
var root = document.body; | |
var height = root.scrollHeight - window.innerHeight | |
+ parseInt(getComputedStyle(root).marginTop, 10) | |
+ parseInt(getComputedStyle(root).marginBottom, 10); | |
var width = root.scrollWidth - window.innerWidth | |
+ parseInt(getComputedStyle(root).marginLeft, 10) | |
+ parseInt(getComputedStyle(root).marginRight, 10); | |
chrome.windows.getCurrent(function (win) { | |
if (win.state !== 'fullscreen') { | |
chrome.windows.update(win.id, { | |
width : win.width + width, | |
height : win.height + height | |
}, function () { | |
Form.nowResizing = false; | |
}); | |
} else { | |
Form.nowResizing = false; | |
} | |
}); | |
return defer(); | |
} | |
return delay(0.5).then(Form.resize); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment