Created
March 9, 2016 04:08
-
-
Save Zequez/cb9a35a9e01fb7c42b50 to your computer and use it in GitHub Desktop.
Rotate screen bookmarklet for those times when someone publishes a rotated picture or anything like that and you don't want to break your neck
This file contains 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
javascript:!function(){___rotate=window.___rotate||0,___rotate++,___rotate>3&&(___rotate=0);var t=document.documentElement,o=t.clientWidth,e=t.clientHeight,r=document.body,i=r.style;0===___rotate?(i.transform="",i.position="",i.width="",i.height="",i.left="",i.top=""):1===___rotate?(i.transform="rotate(90deg)",i.transformOrigin="top left",i.position="absolute",i.width=e+"px",i.height=o+"px",i.left="100%",i.top="0"):2===___rotate?(i.transform="rotate(180deg)",i.transformOrigin="top left",i.position="absolute",i.width=o+"px",i.height=e+"px",i.left="100%",i.top="100%"):3===___rotate&&(i.transform="rotate(270deg)",i.transformOrigin="top left",i.position="absolute",i.width=e+"px",i.height=o+"px",i.left="0",i.top="100%")}(); |
This file contains 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
(function(){ | |
___rotate = window.___rotate || 0; | |
___rotate++; | |
if (___rotate > 3) ___rotate = 0; | |
var doc = document.documentElement; | |
var width = doc.clientWidth | |
var height = doc.clientHeight; | |
var body = document.body; | |
var s = body.style; | |
if (___rotate === 0) { | |
s.transform = ''; | |
s.position = ''; | |
s.width = ''; | |
s.height = ''; | |
s.left = ''; | |
s.top = ''; | |
} else if (___rotate === 1) { | |
s.transform = 'rotate(90deg)'; | |
s.transformOrigin = 'top left'; | |
s.position = 'absolute'; | |
s.width = height + 'px'; | |
s.height = width + 'px'; | |
s.left = '100%'; | |
s.top = '0'; | |
} else if (___rotate === 2) { | |
s.transform = 'rotate(180deg)'; | |
s.transformOrigin = 'top left'; | |
s.position = 'absolute'; | |
s.width = width + 'px'; | |
s.height = height + 'px'; | |
s.left = '100%'; | |
s.top = '100%'; | |
} else if (___rotate === 3) { | |
s.transform = 'rotate(270deg)'; | |
s.transformOrigin = 'top left'; | |
s.position = 'absolute'; | |
s.width = height + 'px'; | |
s.height = width + 'px'; | |
s.left = '0'; | |
s.top = '100%'; | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The bookmarklet needs to wrapped as anonymous function as well else it isn't working. On FF 58.0 0xsJ.js works as expected.