Advertisement
Guest User

chrome extension button_inject

a guest
Aug 30th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. // manifest.json
  2. {
  3. "manifest_version":2,
  4. "version":"1.0.0",
  5. "name": "ButtonInject",
  6. "content_scripts": [
  7. {
  8. "matches": [
  9. "https://*/*",
  10. "http://*/*"
  11. ],
  12. "js": ["script.js"],
  13. "exclude_matches": [
  14. "https://smartbox.localhost/*"
  15. ]
  16. }
  17. ]
  18. }
  19.  
  20. // script.js
  21.  
  22. /**
  23. * Inject a "take me home" button into foreign website
  24. */
  25.  
  26. var button = document.createElement("button");
  27. var label = document.createElement('span');
  28. var icon = new Image();
  29.  
  30. icon.src = 'https://smartbox.localhost/svg/ufs/home.svg';
  31. icon.style.cssText = `
  32. width:64px;
  33. height:64px;
  34. margin:0;
  35. padding:0;
  36. border:0;display:inline;
  37. `;
  38.  
  39. label.innerHTML = 'Menü';
  40. label.style.cssText = `margin:0;
  41. padding:0;
  42. border:0;
  43. display:block;
  44. font-family:sans-serif;
  45. font-size:16px;
  46. color:#fff;
  47. line-height:1em;
  48. text-transform:none;
  49. text-decoration:none;
  50. vertical-align:middle;
  51. padding:0;
  52. `;
  53.  
  54. button.style.cssText = `
  55. margin:0;
  56. padding:0;
  57. border:0;
  58. width:120px;
  59. height:120px;
  60. padding:16px;
  61. border-radius:50%;
  62. overflow:hidden;
  63. position:fixed;
  64. bottom:32px;
  65. left:calc(50vw - 60px);
  66. background-color:rgb(255,90,0);
  67. color:#ffffff;
  68. z-index:50001;
  69. vertical-align:middle;
  70. box-shadow:0px 0px 15px rgba(30, 30, 30, 0.5)
  71. `;
  72.  
  73. button.appendChild(icon);
  74. button.appendChild(label);
  75.  
  76. button.addEventListener('click', function() {
  77. // window.close();
  78. window.location = 'https://smartbox.localhost';
  79. });
  80.  
  81. document.body.insertBefore(button, document.body.firstChild);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement