Exploited Safari Reading List by Advertisers

Safari’s Reading List is really a nice feature and I have been frequently using it to quickly pin webpages and read across Apple devices.

It is so annoying when I find there is some links to webpages I would never be interested in my Reading List, e.g. links to stupid online flash games. I know it must be online advertisers by I really don’t know how they do so. I thought there would be some APIs to Reading List, but I could not find one. After carefully digging the code of the site that adds links to my Reading List, I finally found out the trick.
A running example on jsfiddle.net:

a.hrefopen = function(a) {
        try {
            var c = document.createElement("a");
            c.id = "__qiqi_popup__";
            c.setAttribute("href", a);
            //c.setAttribute("target", "_self");
            c.setAttribute("style", "display:none;");
            var b = document.createEvent("MouseEvents");
            b.initMouseEvent("click", false, false, window, 0, 0, 0, 0, 0, false, false, true, false, 0, null);
            c.dispatchEvent(b);
            return true;
        } catch (q) {
            return false;
        }
    }

Basically, this code simulate a Shift + mouse click on a link to the target webpage, that shortcut in Safari is to add a link to Reading List, while in Chrome, is to open a link in a new window.

Ashamedly, as a developer, I did not know such a API to simulate a mouse event. I personally I do think this API is too powerful. I could not see a very good solution to this problem, but filling a ticket to Apple. I may write a extension to overrides the initMouseEvent to totally get rid of the annoying ads.