Yandex cache link - move from dropdown

29 views
Skip to first unread message

Ciber SLasH

unread,
Apr 17, 2016, 6:56:40 AM4/17/16
to greasemonkey-users
Hello all!
Help please, how make Greasemonkey-script so that in Yandex.Search link to cache move from dropdown menu?
Now:
http://www.imageup.ru/img9/2408608/1.png
there is a wish so:
http://www.imageup.ru/img9/2408609/2.png
my script (attempt):
// ==UserScript==
// @name        Yandex :: Show cache link
// @version        1.00
// @createDate    2016-04-17
// @modifyDate  
// @description    Restore Yandex Cache link
// @include        https://*yandex.*
// ==/UserScript==

var css = "\
span.serp-url__arrow {display: none !important;}\
div.popup2.popup2_target_anchor.popup2_theme_normal.popup2_autoclosable_yes.serp-url__popup.i-bem, div.popup2.popup2_target_anchor.popup2_autoclosable_yes.popup2_theme_normal.extralinks__popup.i-bem {\
    color: black !important;\
    display: block !important;\
    visibility: visible !important;\
    border: 1px solid black !important;\
    background-color: red !important;\
    margin: 0 !important;\
    padding: 0 !important;\
    position: absolute !important;\
    left: 0 !important;\
    top: 0 !important;\
    height: auto !important;\
    line-height: auto !important;\
    z-index: 1000 !important;\
}\
"
;
if (typeof GM_addStyle != "undefined") {
    GM_addStyle
(css);
} else if (typeof PRO_addStyle != "undefined") {
    PRO_addStyle
(css);
} else if (typeof addStyle != "undefined") {
    addStyle
(css);
} else {
   
var heads = document.getElementsByTagName("head");
   
if (heads.length > 0) {
       
var node = document.createElement("style");
        node
.type = "text/css";
        node
.appendChild(document.createTextNode(css));
        heads
[0].appendChild(node);
   
}
}

function linksJob(links) {
   
for (var i=0; i<links.length; i++) {
       
var obj = links[i].nextSibling.lastChild;
        console
.log("className: " + obj.className);
        obj
.style.display = "inline !important";
        obj
.style.visibility = "visible !important";
        obj
.style.border = "1px solid black !important";
   
}
}

var QUERY = 'h2.serp-item__title';
linksJob
(document.querySelectorAll(QUERY));



to work script change about:config
// disable "Content Security Policy"
security.csp.enable: false
Message has been deleted

Ciber SLasH

unread,
Apr 17, 2016, 1:09:32 PM4/17/16
to greasemonkey-users
I do it:
// ==UserScript==
// @name        Yandex :: Show cache link
// @version        1.01
// @author        Ciber SLasH

// @createDate    2016-04-17
// @modifyDate    
// @description    Restore Yandex Cache link
// @include        https://*yandex.*
// ==/UserScript==

function linksJob(links) {
   
for (var i=0; i<links.length; i++) {

       
// div.popup2 popup2_target_anchor popup2_theme_normal popup2_autoclosable_yes serp-url__popup i-bem

       
var obj = links[i].nextSibling.lastChild;

       
for (var j = 1; j < obj.childNodes.length; j++) {
            obj
.removeChild(obj.childNodes[j]);
       
}
       
var curObj = obj.firstChild;
       
if (curObj.tagName == 'A' &&
            curObj
.className.indexOf('link') != -1
       
) {
           
var link = curObj.href;
           
// target: span.serp-url__arrow
           
var targetElemem = curObj.parentNode;
            targetElemem
.previousSibling.setAttribute('style', [
               
'margin-left: 1em !important;',
               
'background: none !important;',
               
'display: inline !important;',
               
'color: black !important;',
           
].join('\r\n'));
           
var newElem = document.createElement('A');
            newElem
.href = link;
            newElem
.text = curObj.text;
            targetElemem
.previousSibling.appendChild(newElem);
Reply all
Reply to author
Forward
0 new messages