Created
March 28, 2023 19:36
-
-
Save vinsworldcom/aef32c1b6b13ae36208845d86cd5921f to your computer and use it in GitHub Desktop.
Tumblr New JavaScript
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 getQueryVariable(variable) { | |
var query = window.location.search.substring(1); | |
var vars = query.split("&"); | |
for (var i=0;i<vars.length;i++) { | |
var pair = vars[i].split("="); | |
if (pair[0] == variable) { | |
return pair[1]; | |
} | |
} | |
} | |
function autoResize(id){ | |
var scaling = 100; | |
var scalingFactor = 5; | |
var width = window.innerWidth | |
|| document.documentElement.clientWidth | |
|| document.body.clientWidth; | |
var height = window.innerHeight | |
|| document.documentElement.clientHeight | |
|| document.body.clientHeight; | |
if (width > scaling*scalingFactor) { | |
width -= scaling; | |
} | |
if (height > scaling*scalingFactor) { | |
height -= scaling; | |
} | |
var orig =document.getElementById(id); | |
orig.height = height; | |
orig.width = width; | |
var world = getQueryVariable("world"); | |
if (world != null) { | |
var unescapedurl = unescape(world); | |
var fullurl = 'https://drive.google.com/uc?export=view&id=' + unescapedurl; | |
var clone=orig.cloneNode(true); | |
clone.setAttribute('src',fullurl); | |
orig.parentNode.replaceChild(clone,orig); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment