-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
31 lines (27 loc) · 954 Bytes
/
content.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function parseQuery(queryString) {
var query = {};
var pairs = (queryString[0] === "?" ? queryString.substr(1) : queryString).split("&");
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i].split("=");
query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || "");
}
return query;
}
var element = document.createElement("button");
element.onclick = () => {
const { q, iax } = parseQuery(window.location.search);
window.location.href =
"https://google.com/search?q=" + (q ? q : "") + (iax && iax === "images" ? "&tbm=isch" : "") + (iax && iax === "videos" ? "&tbm=vid" : "");
};
element.style = `
background-color: #66ad57;
border-radius: 4px;
color: white;
font-size: 16px;
border: none;
padding: 8px;
margin-left: 16px;
`;
element.appendChild(document.createTextNode("I was unlucky"));
var page = document.getElementsByClassName("js-header-aside")[0];
page.appendChild(element);