Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- alert("Click the text of the comment you want a link to.");
- document.body.onclick = function(e) {
- var clearance_height, element, id, offset_height, post, sibling_cursor, sibling_element, sibling_elements, sibling_ids, url, _i, _j, _len;
- element = e.toElement;
- _i = 10;
- while (_i > 0 && !id) {
- if (element.parentNode && element.parentNode.className === "qx rg") {
- id = element.parentNode.id;
- }
- element = element.parentNode;
- _i--;
- }
- sibling_ids = [];
- sibling_elements = element.parentNode.getElementsByClassName("qx rg");
- clearance_height = 0;
- offset_height = 0;
- if (window.innerHeight >= 530) {
- clearance_height += document.getElementById("gb").offsetHeight || 30;
- }
- if (window.innerHeight >= 800) {
- clearance_height += document.getElementsByClassName("c-cb-V c-i-cb-V c-cb-V-Fi")[0].offsetHeight || 60;
- }
- for (_j = 0, _len = sibling_elements.length; _j < _len; _j++) {
- sibling_element = sibling_elements[_j];
- sibling_ids.push(sibling_element.id);
- }
- sibling_cursor = sibling_ids.indexOf(element.id);
- while (offset_height < clearance_height && sibling_cursor > 0) {
- sibling_cursor -= 1;
- offset_height += sibling_elements[sibling_ids[sibling_cursor]].offsetHeight;
- }
- if (sibling_ids && sibling_ids.indexOf(sibling_cursor)) {
- id = sibling_ids[sibling_cursor];
- }
- if (!id) {
- return alert("No comment ID found, try clicking on the actual text of the comment.");
- } else {
- url = window.location.href;
- post = url.split("google.com/")[1];
- url = window.location.protocol + "//" + window.location.hostname + "#" + post + "#" + post + "#" + id;
- return alert(url);
- }
- };
- }).call(this);
Advertisement
Add Comment
Please, Sign In to add comment