Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // manifest.json
- {
- "manifest_version":2,
- "version":"1.0.0",
- "name": "ButtonInject",
- "content_scripts": [
- {
- "matches": [
- "https://*/*",
- "http://*/*"
- ],
- "js": ["script.js"],
- "exclude_matches": [
- "https://smartbox.localhost/*"
- ]
- }
- ]
- }
- // script.js
- /**
- * Inject a "take me home" button into foreign website
- */
- var button = document.createElement("button");
- var label = document.createElement('span');
- var icon = new Image();
- icon.src = 'https://smartbox.localhost/svg/ufs/home.svg';
- icon.style.cssText = `
- width:64px;
- height:64px;
- margin:0;
- padding:0;
- border:0;display:inline;
- `;
- label.innerHTML = 'Menü';
- label.style.cssText = `margin:0;
- padding:0;
- border:0;
- display:block;
- font-family:sans-serif;
- font-size:16px;
- color:#fff;
- line-height:1em;
- text-transform:none;
- text-decoration:none;
- vertical-align:middle;
- padding:0;
- `;
- button.style.cssText = `
- margin:0;
- padding:0;
- border:0;
- width:120px;
- height:120px;
- padding:16px;
- border-radius:50%;
- overflow:hidden;
- position:fixed;
- bottom:32px;
- left:calc(50vw - 60px);
- background-color:rgb(255,90,0);
- color:#ffffff;
- z-index:50001;
- vertical-align:middle;
- box-shadow:0px 0px 15px rgba(30, 30, 30, 0.5)
- `;
- button.appendChild(icon);
- button.appendChild(label);
- button.addEventListener('click', function() {
- // window.close();
- window.location = 'https://smartbox.localhost';
- });
- document.body.insertBefore(button, document.body.firstChild);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement