Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Web Image Rotate Widget

AlanKuan May 17th, 2020 (edited) 1,038 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Author: 小恩 Alan Kuan
  3. Description: A simple tool to rotate images on a web page.
  4. Usage:
  5.     1. Add codes below to bookmarks in your browser.
  6.     2. View an image in a new tab.
  7.     3. Click the bookmarks as you like to rotate the image.
  8. Version: 1.0
  9. Change log:
  10.     1.0:
  11.         - Change to use custom attributes to store the value of rotated degree.
  12. */
  13.  
  14. // Rotate Left
  15. javascript:(
  16.     function(){
  17.         var img = document.getElementsByTagName("img")[0];
  18.        
  19.         if(img.n_img_deg == 0){
  20.             img.style.transform = 'rotate(270deg)';
  21.             img.n_img_deg = 270;
  22.         }else if(img.n_img_deg == 90){
  23.             img.style.transform = 'rotate(0deg)';
  24.             img.n_img_deg = 0;
  25.         }else if(img.n_img_deg == 180){
  26.             img.style.transform = 'rotate(90deg)';
  27.             img.n_img_deg = 90;
  28.         }else if(img.n_img_deg == 270){
  29.             img.style.transform = 'rotate(180deg)';
  30.             img.n_img_deg = 180;
  31.         }else{
  32.             img.style.transform = 'rotate(270deg)';
  33.             img.n_img_deg = 270;
  34.         }
  35.     }
  36. )();
  37.  
  38. // Rotate Right
  39. javascript:(
  40.     function(){
  41.         var img = document.getElementsByTagName("img")[0];
  42.  
  43.         if(img.n_img_deg == 0){
  44.             img.style.transform = 'rotate(90deg)';
  45.             img.n_img_deg = 90;
  46.         }else if(img.n_img_deg == 90){
  47.             img.style.transform = 'rotate(180deg)';
  48.             img.n_img_deg = 180;
  49.         }else if(img.n_img_deg == 180){
  50.             img.style.transform = 'rotate(270deg)';
  51.             img.n_img_deg = 270;
  52.         }else if(img.n_img_deg == 270){
  53.             img.style.transform = 'rotate(0deg)';
  54.             img.n_img_deg = 0;
  55.         }else{
  56.             img.style.transform = 'rotate(90deg)';
  57.             img.n_img_deg = 90;
  58.         }
  59.     }
  60. )();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top