Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. {
  2. "manifest_version": 2,
  3. "name": "Such Activity",
  4. "description": "Wow",
  5. "version": "1.0",
  6. "permissions": ["tabs", "<all_urls>"],
  7. "browser_action": {
  8. "default_icon": {
  9. "19": "images/icons/19.png",
  10. "38": "images/icons/38.png"
  11. },
  12. "default_popup": "popup.html"
  13. },
  14. "icons": {
  15. "16": "images/icons/16.png",
  16. "19": "images/icons/19.png",
  17. "38": "images/icons/38.png",
  18. "64": "images/icons/64.png",
  19. "128": "images/icons/128.png"
  20. }
  21. }
  22.  
  23. function injectTheScript() {
  24. chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
  25. // query the active tab, which will be only one tab
  26. //and inject the script in it
  27. chrome.tabs.executeScript(tabs[0].id, {file: "content_script.js"});
  28. });
  29. }
  30. document.getElementById('clickactivity').addEventListener('click', injectTheScript);
  31.  
  32. function clickSome() {
  33. function getElementsByText(text) {
  34. function rec(ele, arr)
  35. {
  36. if (ele.childNodes.length > 0)
  37. for (var i = 0; i < ele.childNodes.length; i++)
  38. rec(ele.childNodes[i], arr);
  39. else if (ele.nodeType == Node.TEXT_NODE &&
  40. ele.nodeValue.indexOf(text) != -1)
  41. arr.push(ele.parentNode);
  42. return arr;
  43. }
  44. return rec(document.body, []);
  45. }
  46. var x = 'Text';
  47. var my = getElementsByText(x.ignoreCase);
  48. var mod =my[0];
  49. console.log(my);
  50. document.getElementsByClassName(mod)[0].click();
  51. }
  52. clickSome();
  53.  
  54. <!doctype html>
  55. <html>
  56. <head><title>activity</title></head>
  57. <body>
  58. <button id="clickactivity">click</button>
  59. <script src="popup.js"></script>
  60. </body>
  61. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement