techlover0010 / 3D BH

// ==UserScript==
// @name         3D BH
// @namespace    https://www.brick-hill.com/user?id=5
// @version      1.22
// @changelog    +Fixed graphical glitch and removed backround attr to be used with themes. +Fixed new site URL. +Fixed try button not working.
// @description  Add 360 3D item and user spin arounds!
// @author       Tech
// @match        https://www.brick-hill.com/shop/item?id=*
// @match        https://www.brick-hill.com/user?id=*
// @run-at       document-start
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @license      MIT
// ==/UserScript==
if(window.localStorage.threed == '' && window.localStorage.threed == null) {
    window.localStorage.threed = 'false';
    console.log(window.localStorage.threed);
}
$('head').ready(function () {
  var usrID = $('span span a[href*="/user?id="]:first-of-type').attr("href").replace(/\D/g, '');
  var id = $('meta[property="og:url"]').attr("content").replace(/\D/g, '');
  $('img[style="width: 235px;height: 280px;border:0px;"]').wrap('<div id="usrImg" style="width: 395px;height: 280px;margin-left: 75px;"></div>');
  $('#usrImg').prepend(`<button style="color: #fff;font-size: 14px;position: absolute;margin-top: 259px;margin-left: 44px;z-index:2;" id="3Dbtn" onclick="myFunctiono()">3D</button>`);
  $('#usrImg').append(`<iframe id="3Difrme2" src="https://techsworld.000webhostapp.com/3D/3davatar.php?id=` + id + `" style="border: 0px solid black; background: none; width: 235px; height: 280px; display: block;"></iframe>`);
  $('#shopItem').wrap('<div id="shopItmImg"></div>');
  $('#shopItem').before(`<button style="color: #fff;position: absolute;margin: 308px;font-size: 18px;margin-left: 306px;z-index:995;" id="3Dbtn" onclick="myFunction()">3D</button>`)
  $('#shopItem').before(`<button style="color: #fff;position: absolute;margin: 308px;font-size: 18px;margin-left: 18px;z-index:995;" id="tryBtn" onclick="tryOn()">Try On</button>`)
  $('#shopItem').after(`<iframe id="3Difrme" src="https://techsworld.000webhostapp.com/3D/?id=` + id + `" style="float: left;margin: 0px 10px;width: 340px;height: 340px;border: 1px solid black;background: white;display: none;"></iframe>`);
  $('#shopItem').after(`<iframe id="tryifrme" src="https://techsworld.000webhostapp.com/3D/try.php?id=` + usrID + `&try=` + id + `" style="float: left;margin: 0px 10px;width: 340px;height: 340px;border: 1px solid black;background: white;display: none;"></iframe>`);
  $('head').append(`<script>function myFunction() {
  var x = document.getElementById("3Dbtn");
var is3D = window.localStorage.threed;
  if (x.innerHTML === "3D") {
    if(is3D == 'true') {
    window.localStorage.threed = 'false';
console.log(window.localStorage.threed);

    x.innerHTML = "2D";
    $('#shopItem').css("display","none");
    $('#3Difrme').css("display","block");
    $('#tryBtn').css("display","none");
}
  } else {
        if(is3D == 'false') {
    window.localStorage.threed = 'true';
console.log(window.localStorage.threed);

    x.innerHTML = "3D";
    $('#shopItem').css("display","block");
    $('#3Difrme').css("display","none");
    $('#tryBtn').css("display","block");
}
  }
}</script>`);
    //shop
    //
    //
    var is3D = window.localStorage.threed;
      var x = document.getElementById("3Dbtn");

    if(is3D == 'false') {
console.log(window.localStorage.threed);

    x.innerHTML = "2D";
    $('#shopItem').css("display","none");
    $('#3Difrme').css("display","block");
    $('#tryBtn').css("display","none");
} else {
if(is3D == 'true') {
console.log(window.localStorage.threed);

    x.innerHTML = "3D";
    $('#shopItem').css("display","block");
    $('#3Difrme').css("display","none");
    $('#tryBtn').css("display","block");
}
}
  $('head').append(`
<script>function tryOn() {
  var g = document.getElementById("tryBtn");
  if (g.innerHTML === "Try On") {
    g.innerHTML = "Reset";
    $('#shopItem').css("display","none");
    $('#tryifrme').css("display","block");
    $('#3Dbtn').css("display","none");

  } else {
    g.innerHTML = "Try On";
    $('#shopItem').css("display","block");
    $('#tryifrme').css("display","none");
    $('#3Dbtn').css("display","block");
  }
}</script>`);
  $('head').append(`<style> button:focus {outline: none!important; }#body #column:first-of-type #box:first-of-type, #body #column:first-of-type #box:nth-of-type(3){overflow-x: hidden;}</style>
`);
  $('img[style="width: 235px;height: 280px;border:0px;"]').addClass('userImgCl');
  $('.userImgCl').css("display", "block");
  $('#3Difrme2').css("display", "none");
  $('head').append(`<script>function myFunctiono() {
  var y = document.getElementById("3Dbtn");
var is3D = window.localStorage.threed;
  if (y.innerHTML === "3D") {
    if(is3D == 'true') {
    window.localStorage.threed = 'false';
console.log(window.localStorage.threed);

    y.innerHTML = "2D";
    $('.userImgCl').css("display","none");
    $('#3Difrme2').css("display","block");
}
  } else {
    if(is3D == 'false') {
    window.localStorage.threed = 'true';
console.log(window.localStorage.threed);

    y.innerHTML = "3D";
    $('.userImgCl').css("display","block");
    $('#3Difrme2').css("display","none");
}
  }
}</script>`)
});