Skip to content

Commit

Permalink
Update v0.4.9 - Automatically download as landscape
Browse files Browse the repository at this point in the history
  • Loading branch information
isanchop committed Jan 7, 2023
1 parent 84a6931 commit 2d74181
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion doc-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,23 @@ window.addEventListener('load', function(){
var tit = document.getElementsByTagName("h1")[0].innerHTML;
var pages = document.getElementById('page-container').childNodes;

width = pages[0].offsetWidth;
height = pages[0].offsetHeight;

if (width > height){
print_opt = "{@page {size: A5 landscape;} body {zoom: 90%;}";
}else{
print_opt = "{@page {size: A5 portrait;}";
}

for(i=0; i<pages.length; i++){
pages[i].childNodes[0].style = "display: block;";
}

var pdf = pages[0].parentNode.parentNode.parentNode.innerHTML;

newWindow = window.open("", "Document", "height=865,width=625,status=yes,toolbar=no,menubar=no");
newWindow.document.getElementsByTagName("head")[0].innerHTML = head + "<style> .nofilter{filter: none !important;} </style>" + "<style> @media print {@page {size: A5;}}</style>";
newWindow.document.getElementsByTagName("head")[0].innerHTML = head + "<style> .nofilter{filter: none !important;} </style>" + "<style> @media print " + print_opt + "</style>";
newWindow.document.title = tit;
newWindow.document.getElementsByTagName("body")[0].innerHTML = pdf;
newWindow.document.getElementsByTagName("body")[0].childNodes[0].style = "";
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,

"name": "StuHack",
"version": "0.4.8",
"version": "0.4.9",
"description": "Banner remover, filter pass & document downloader",
"icons": {
"16": "img/icon16.png",
Expand Down

0 comments on commit 2d74181

Please sign in to comment.