Results 1 to 6 of 6

Thread: Copying text adds additional information to the clipboard

  1. #1
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default Copying text adds additional information to the clipboard

    I have found some websites that attach extra text (usually citation information and URL) to the end of text copied from webpages.

    Two examples:
    informahealthcare.com/doi/abs/10.3109/02699208808985246
    ethos.bl.uk/OrderDetails.do?uin=uk.bl.ethos.376051
    I've also seen this on some news (eg, newspaper) websites.

    Select any text on the page, then copy it and paste it to a new document. You'll find that additional text is added to whatever you selected.


    I have two questions:

    Just out of curiosity:
    1. How is this done? Is it Javascript?

    More importantly:
    2. Is there any way that I can disable this in my browser? (I use Firefox, but general answers or for other browsers are fine too.)

    I find this to be incredibly annoying because, as you can see from the links I posted above, I'm trying to use these websites for bibliographic information and I want to copy and paste titles, authors' names, etc. I will even include a link to those pages where appropriate. But the websites insist on informing me every time where the data is from (I know that, of course), and then I need to remove it.

    I really don't see the point in this because it's not like someone is going to copy and paste text, ignore the additional information, then post it somewhere for the world to see so they can click on the link.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Yes.

    Disable javascript.

    There might also be some counter javascript code that you can run to unbind the event. But I would want to see the uncompressed version of the code used to create it in the first place. This could conceivably vary from site to site as well. And the countermanding code - if any, would probably vary from browser to browser too.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    djr33 (10-16-2014)

  4. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I'm looking at the minimized code used by your first example. It looks like it attaches the event in multiple ways, using whatever javascript libraries might be available on the page as well as the standard javascript addEventListener method. Turning off one or two of these might not be enough to stop the code from executing.

    How big of a deal is this? You can always paste your selection and then cut/delete the added byline.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Not that big of a deal. I've been busy and haven't thought of it for a couple days, but I'm just interested in it conceptually. I can certainly fix it manually, but that gets tiresome (to where I sometimes just type out the line of text by hand rather than cutting and pasting).

    I suspected it might be a layered approach that would be intentionally difficult to circumvent. Really absurd in my opinion, given that it doesn't stop anything or help anything. It's just like placing a sticker on everyone as they walk out of a store-- they'll take them off and be less inclined to return.

    Thanks for looking into it! I am glad at least to know that this is in fact Javascript. It seems like something browsers should reject, as they often do with no-right-click scripts. (I'd like to add such things to a browser plugin at some point...)
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #5
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,832
    Thanks
    49
    Thanked 244 Times in 237 Posts
    Blog Entries
    56

    Default

    It's done with javascript alright.
    informahealthcare.com/doi/abs/10.3109/02699208808985246 achieves it via a js-file oncopy.js, which has the following:
    Code:
    (function(){var r=function(w,k){var j=document,g=j.body,l=j.documentElement,i=window,s=function(){var a=i.OnCopy||{};a.SEPARATOR=a.SEPARATOR||"<br/></br/>";a.READ_MORE=a.READ_MORE||"Read More: ";a.URL=a.URL||i.location.href;a.TITLE=a.TITLE||(j.title||i.location.hostname).toString().replace(RegExp(i.location.hash,"g"),"");if(a.USE_URL_AS_TITLE===k)a.USE_URL_AS_TITLE=true;if(a.USE_URL_AS_TITLE)a.TITLE=a.URL;a.SELECTOR=a.SELECTOR||"#articleContent";a.WORDS_MIN=a.WORDS_MIN||7;a.STRIP=a.STRIP||"script";
    return a},h=s(),t=function(a,d){for(var b in d)if(d.hasOwnProperty(b))a.style[b]=d[b]},m=function(a,d,b){a=j.createElement(a);if(d!==k){var e=a,c;for(c in d)if(d.hasOwnProperty(c))e[c]=d[c]}b!==k&&t(a,b);return a},p=function(a){i.setTimeout(a,0)},u=function(a){var d=m("div"),b=m("span",{innerHTML:h.SEPARATOR+h.READ_MORE+'<a href="'+h.URL+'">'+h.TITLE+"</a>"});if(typeof a=="string")d.innerHTML=a;else d.appendChild(a);d.appendChild(m("br"));d.appendChild(b);a=d;if(b=h.STRIP){b=b.split(" ");for(var e=
    0;e<b.length;++e){a=a.getElementsByTagName(b[e]);for(var c=a.length-1;c>=0;c--){var f=a[c];f.parentNode.removeChild(f)}}}return d},n=false,q=function(){var a=function(){var b=i.getSelection();if(b.toString()){var e=b.getRangeAt(0),c=u(e.cloneContents());if(b.setBaseAndExtent!==k){t(c,{width:1,height:1,position:"absolute",left:"-10000px",top:"-10000px"});c.appendChild(m("br"));g.insertBefore(c,g.firstChild);b.selectAllChildren(c);p(function(){c.parentNode.removeChild(c);i.getSelection().setBaseAndExtent(e.startContainer,
    e.startOffset,e.endContainer,e.endOffset);n=false})}else{var f=m("div");g.appendChild(f);f.appendChild(c);var o=j.createRange();o.selectNode(c);b.removeAllRanges();b.addRange(o);p(function(){f.parentNode.removeChild(f);b.removeAllRanges();b.addRange(e);n=false})}}},d=function(){var b={left:l.scrollLeft?l.scrollLeft:g.scrollLeft,top:l.scrollTop?l.scrollTop:g.scrollTop},e=m("div",{},{visibility:"hidden",overflow:"hidden",position:"absolute",left:b.left+"px",top:b.top+"px",width:"1px",height:"1px"});
    g.insertBefore(e,g.firstChild);var c=j.selection.createRange(),f=u(c.htmlText);e.appendChild(f);var o=g.createTextRange();o.moveToElementText(f);o.select();p(function(){e.parentNode.removeChild(e);c.select();l.scrollLeft=b.left;g.scrollLeft=b.left;l.scrollTop=b.top;g.scrollTop=b.top;n=false})};q=i.getSelection!==k?a:d;q()},v=function(a){if(n)return false;h=s();var d=i.getSelection!==k?i.getSelection().toString():j.selection.createRange().text;if((d?d.split(/\s+/).length:0)>=h.WORDS_MIN){a=a.target||
    a.srcElement;var b=true;if(h.SELECTOR&&h.SELECTOR!=""){b=false;var e=d=null;if(h.SELECTOR.charAt(0)==".")e=h.SELECTOR.substring(1);else d=h.SELECTOR.substring(1);for(;a&&!b;){if(e)a:{var c=e;if(a.className){b=a.className.split(" ");c=c.toUpperCase();for(var f=0;f<b.length;f++)if(b[f].toUpperCase()==c){b=true;break a}}b=false}else b=d==a.id;b=b;a=a.parentNode}}if(b){n=true;q()}}return true};i.addEventListener?g.addEventListener("copy",v,false):g.attachEvent("oncopy",v)};if(typeof jQuery!="undefined")jQuery(document).ready(r);
    else if(typeof window.Prototype!="undefined")document.observe("dom:loaded",r);else typeof YAHOO!="undefined"&&YAHOO.util.Event.onDOMReady(r)})();
    I don't know about the other site because it's inaccessible at the moment.
    If both sites use the same javascript for info added oncopy, then it might be possible to write a plugin that destroys it.
    Last edited by molendijk; 10-16-2014 at 11:42 AM. Reason: typo

  7. The Following User Says Thank You to molendijk For This Useful Post:

    djr33 (10-19-2014)

  8. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This just happened to me as I was annotating a friend's post on FB. But, it was actually a good thing. It automatically provided a link back to my source for anyone wanting even more information.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. random text with additional information
    By piddle in forum JavaScript
    Replies: 0
    Last Post: 05-12-2014, 05:07 PM
  2. Copying text from my site
    By tgallagher26 in forum PHP
    Replies: 2
    Last Post: 03-04-2009, 01:55 PM
  3. Copying Text from another site
    By tgallagher26 in forum Looking for such a script or service
    Replies: 8
    Last Post: 02-26-2009, 10:06 PM
  4. Copying Text
    By Trinithis in forum JavaScript
    Replies: 1
    Last Post: 06-14-2007, 05:03 PM
  5. Replies: 0
    Last Post: 04-02-2007, 08:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •