Last active
February 24, 2016 03:27
-
-
Save debbbbie/b8792d475ab3feec5750 to your computer and use it in GitHub Desktop.
tampermonkey/ruten
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Ruten | |
// @namespace http://debbbbie.com/ | |
// @version 1.0 | |
// @description Ruten | |
// @author debbbbie | |
// @updateURL https://gist.githubusercontent.com/debbbbie/b8792d475ab3feec5750/raw/5788cbe0aefdccd75690a9e50c6fae4450454ddb/tampermonkey.js | |
// @match http://mybid.ruten.com.tw/* | |
// @match http://goods.ruten.com.tw/* | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js | |
// @grant none | |
// ==/UserScript== | |
window.blank_target = function(match, dom){ | |
if(document.location.href.indexOf(match) >= 0){ | |
console.log('matched'); | |
$(dom).find('a').each(function(){ | |
if($(this).attr('href').indexOf('#')!=0){ | |
$(this).attr('target', '_blank'); | |
} | |
}); | |
} | |
} | |
window.pend_nav = function(navs, options){ | |
var str = '<div style="position: fixed; top: '+options.top+'px; right: '+options.right+'px; border: 1px solid black; border-radius: 4px; padding: 4px 4px 4px 4px;z-index: 999">'; | |
for(var i = 0; i < navs.length; i++){ | |
str += ' <a href="'+ navs[i][1]+ '">'+ navs[i][0]+ '</a>'; | |
if(i < navs.length-1) str += ' | '; | |
} | |
str+='</div>'; | |
$(document.body).append(str); | |
} | |
window.show_kfz_url = function(match, dom){ | |
if(document.location.href.indexOf(match) >= 0){ | |
kfz_id = $("#user_generated_content iframe").contents().find(dom).text() ; | |
if (new RegExp(/\d{3,6}\/\d{9}/).test( kfz_id )){ | |
pend_nav([ | |
["KFZ", "http://book.kongfz.com/"+kfz_id], | |
["商品管理", "http://mybid.ruten.com.tw/master/my.php?l_type=sel_selling"] | |
], {top: 50, right: 50}); | |
} | |
} | |
} | |
function main(){ | |
blank_target('http://mybid.ruten.com.tw', '.mybid-table'); | |
show_kfz_url('http://goods.ruten.com.tw', '.product-content span[style*="color:white"]'); | |
} | |
$.noConflict(); | |
jQuery( document ).ready(function($) { | |
main(); | |
$(window).bind("replacestate", function() { | |
alert(3); | |
main(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment