Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save hilyjiang/1d6729c3db0c8fe1bb99 to your computer and use it in GitHub Desktop.

Select an option

Save hilyjiang/1d6729c3db0c8fe1bb99 to your computer and use it in GitHub Desktop.

Revisions

  1. hilyjiang revised this gist Jul 23, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gmail_remove_image_proxy.user.js
    Original file line number Diff line number Diff line change
    @@ -49,4 +49,4 @@ setTimeout(function() {
    hideAnchor.innerHTML = '×';
    divElem.appendChild(hideAnchor);
    document.getElementsByTagName('body')[0].appendChild(divElem);
    }, 2000);
    }, 5000);
  2. hilyjiang revised this gist Jul 23, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gmail_remove_image_proxy.user.js
    Original file line number Diff line number Diff line change
    @@ -24,13 +24,13 @@ setTimeout(function() {
    anchorElem.addEventListener('click', function () {
    var img, elem, src;
    // img src
    while (img = document.evaluate('//img[contains(@src, \'googleusercontent.com\')]', document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue) {
    while (img = document.evaluate('//img[contains(@src, \'googleusercontent.com\') and contains(@src, \'#http\')]', document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue) {
    src = img.attributes.src.value;
    src = src.substr(src.indexOf('#') + 1);
    img.attributes.src.value = src;
    }
    // CSS background url etc
    while (elem = document.evaluate('//*[contains(@style,\'googleusercontent.com\')]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue) {
    while (elem = document.evaluate('//*[contains(@style,\'googleusercontent.com\') and contains(@src, \'#http\')]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue) {
    style = elem.attributes.style.value;
    style = style.replace(/url\(([^\)#]*)#([^\)]*)\)/, "url($2)");
    elem.attributes.style.value = style;
  3. @oradwell oradwell revised this gist Mar 3, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gmail_remove_image_proxy.user.js
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    // ==UserScript==
    // @name Gmail remove gstatic
    // @namespace https://mail.google.com/mail/u/*/*
    // @namespace ockcyp/gmail-remove-gstatic
    // @version 0.1
    // @description enter something useful
    // @description Remove gstatic from external image URLs (useful when URLs contain internal domains)
    // @author ockcyp
    // @grant none
    // ==/UserScript==
  4. @oradwell oradwell revised this gist Oct 31, 2014. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion gmail_remove_image_proxy.user.js
    Original file line number Diff line number Diff line change
    @@ -22,12 +22,19 @@ setTimeout(function() {
    var anchorElem = document.createElement('a');
    anchorElem.setAttribute('href', '#');
    anchorElem.addEventListener('click', function () {
    var img, src;
    var img, elem, src;
    // img src
    while (img = document.evaluate('//img[contains(@src, \'googleusercontent.com\')]', document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue) {
    src = img.attributes.src.value;
    src = src.substr(src.indexOf('#') + 1);
    img.attributes.src.value = src;
    }
    // CSS background url etc
    while (elem = document.evaluate('//*[contains(@style,\'googleusercontent.com\')]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue) {
    style = elem.attributes.style.value;
    style = style.replace(/url\(([^\)#]*)#([^\)]*)\)/, "url($2)");
    elem.attributes.style.value = style;
    }
    return false;
    });
    anchorElem.setAttribute('style', 'text-decoration:none;color:black;margin-right:5px');
  5. @oradwell oradwell created this gist Oct 31, 2014.
    45 changes: 45 additions & 0 deletions gmail_remove_image_proxy.user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    // ==UserScript==
    // @name Gmail remove gstatic
    // @namespace https://mail.google.com/mail/u/*/*
    // @version 0.1
    // @description enter something useful
    // @author ockcyp
    // @grant none
    // ==/UserScript==
    setTimeout(function() {
    // Page is loaded and the div is not already created
    if (document.title.match(/@/) === null || document.getElementById('remove_img_proxy_div')) {
    return;
    }

    var textNode = document.createTextNode("Don't use Image Proxy");
    // The div containing the links
    var divElem = document.createElement('div');
    divElem.setAttribute('style', 'position:absolute;bottom:15px;'
    + 'font-size:12px;background-color:#EFF;padding:10px;margin:auto');
    divElem.setAttribute('id', 'remove_img_proxy_div');
    // Link to disable proxy
    var anchorElem = document.createElement('a');
    anchorElem.setAttribute('href', '#');
    anchorElem.addEventListener('click', function () {
    var img, src;
    while (img = document.evaluate('//img[contains(@src, \'googleusercontent.com\')]', document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue) {
    src = img.attributes.src.value;
    src = src.substr(src.indexOf('#') + 1);
    img.attributes.src.value = src;
    }
    return false;
    });
    anchorElem.setAttribute('style', 'text-decoration:none;color:black;margin-right:5px');
    anchorElem.appendChild(textNode);
    divElem.appendChild(anchorElem);

    // Link to hide the button
    var hideAnchor = document.createElement('a');
    hideAnchor.setAttribute('href', '#');
    hideAnchor.setAttribute('style', 'text-decoration:none;color:black;font-size:14px');
    hideAnchor.setAttribute('onclick', "document.getElementsByTagName('body')[0].removeChild(document.getElementById('remove_img_proxy_div'))");
    hideAnchor.innerHTML = '×';
    divElem.appendChild(hideAnchor);
    document.getElementsByTagName('body')[0].appendChild(divElem);
    }, 2000);