Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Commit cd46fa6

Browse files
committed
v1.0
1 parent 8eab9f0 commit cd46fa6

File tree

7 files changed

+133
-1
lines changed

7 files changed

+133
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# view-image-button
2-
A Safari extension that re-enables the 'view image' button in Google image search
2+
A Safari extension that re-enables the 'view image' button in Google image search
3.56 KB
Loading
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>Author</key>
6+
<string>Justin Wasack</string>
7+
<key>Builder Version</key>
8+
<string>13605.3.8</string>
9+
<key>CFBundleDisplayName</key>
10+
<string>View Image Button</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>com.quoid.viewimagebutton</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleShortVersionString</key>
16+
<string>1.0</string>
17+
<key>CFBundleVersion</key>
18+
<string>1</string>
19+
<key>Content</key>
20+
<dict>
21+
<key>Scripts</key>
22+
<dict>
23+
<key>End</key>
24+
<array>
25+
<string>view-image-button.js</string>
26+
</array>
27+
</dict>
28+
</dict>
29+
<key>Description</key>
30+
<string>Re-enables the 'view image' button in Google image search</string>
31+
<key>DeveloperIdentifier</key>
32+
<string>J74Q8V8V8N</string>
33+
<key>ExtensionInfoDictionaryVersion</key>
34+
<string>1.0</string>
35+
<key>Permissions</key>
36+
<dict>
37+
<key>Website Access</key>
38+
<dict>
39+
<key>Allowed Domains</key>
40+
<array>
41+
<string>*.google.com</string>
42+
</array>
43+
<key>Include Secure Pages</key>
44+
<true/>
45+
<key>Level</key>
46+
<string>Some</string>
47+
</dict>
48+
</dict>
49+
<key>Update Manifest URL</key>
50+
<string>https://raw.githubusercontent.com/quoid/view-image-button/master/update.plist</string>
51+
<key>Website</key>
52+
<string>https://github.com/quoid/view-image-button</string>
53+
</dict>
54+
</plist>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
function addButton(el) {
2+
var img_src = el.getAttribute("src");
3+
4+
var container = el.closest(".irc_c");
5+
var buttons = container.querySelector(".irc_but_r tr");
6+
7+
var view_button = buttons.querySelector(".gisvi");
8+
9+
if (view_button === null) {
10+
console.info("view image button not created, making one");
11+
var clone_button = buttons.querySelector("td");
12+
view_button = clone_button.cloneNode(true);
13+
view_button.classList.add("gisvi");
14+
view_button.querySelector("a span:nth-child(2)").innerText = "View Image";
15+
view_button.querySelector("a span:nth-child(1)").className = "";
16+
view_button.querySelector("a span:nth-child(1)").innerHTML = "";
17+
18+
var link = view_button.querySelector("a");
19+
link.href = img_src;
20+
link.className = "";
21+
link.removeAttribute("data-cthref");
22+
link.removeAttribute("jsaction");
23+
24+
buttons.appendChild(view_button);
25+
}
26+
27+
var link = view_button.querySelector("a");
28+
link.href = img_src;
29+
}
30+
31+
function check_page() {
32+
var p = document.querySelector(".hdtb-msel"); //google search tab selector
33+
34+
if (p != null && p.innerText === "Images") { //if tab selector exists and 'Images' selected
35+
console.info("google images search detected - enabling 'view image' buttons");
36+
37+
var targetNode = document.getElementById("gsr");
38+
39+
var config = { childList: true, subtree: true };
40+
41+
var callback = function(mutationsList, observer) {
42+
for(var mutation of mutationsList) {
43+
var nodes = mutation.addedNodes;
44+
nodes.forEach(function(node) {
45+
if (node.nodeType === Node.ELEMENT_NODE && node.classList.contains("irc_mi")) {
46+
addButton(node);
47+
}
48+
});
49+
}
50+
};
51+
52+
var observer = new MutationObserver(callback);
53+
observer.observe(targetNode, config);
54+
}
55+
}
56+
57+
check_page();

ViewImageButton.safariextz

12.5 KB
Binary file not shown.

screenshot.png

710 KB
Loading

update.plist

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>Extension Updates</key>
6+
<array>
7+
<dict>
8+
<key>CFBundleIdentifier</key>
9+
<string>com.quoid.viewimagebutton</string>
10+
<key>Developer Identifier</key>
11+
<string>J74Q8V8V8N</string>
12+
<key>CFBundleVersion</key>
13+
<string>1.0.0</string>
14+
<key>CFBundleShortVersionString</key>
15+
<string>1.0.0</string>
16+
<key>URL</key>
17+
<string>https://raw.githubusercontent.com/quoid/view-image-button/master/coin_ticker.safariextz</string>
18+
</dict>
19+
</array>
20+
</dict>
21+
</plist>

0 commit comments

Comments
 (0)