Skip to content

Instantly share code, notes, and snippets.

@ailispaw
Last active January 6, 2020 13:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ailispaw/3a62870d1f6e7a7a9a7b489adb865d64 to your computer and use it in GitHub Desktop.
Save ailispaw/3a62870d1f6e7a7a9a7b489adb865d64 to your computer and use it in GitHub Desktop.
Taberareloo: Fix the size of the popup window
// ==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